【发布时间】:2012-02-11 03:45:16
【问题描述】:
我正在尝试使用 Python matplotlib 打印 600 dpi 图形。但是 Python 绘制了 8 个图形中的 2 个,并输出错误:
OverflowError: Agg rendering complexity exceeded. Consider downsampling or decimating your data.
我正在绘制大量数据(每列 7,500,000 个数据),所以我猜这可能是一些过载问题,或者我需要设置一个大的 cell_block_limit。
我尝试在 Google 上搜索更改 cell_block_limit 的解决方案,但无济于事。什么是好的方法?
代码如下:-
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
majorLocator = MultipleLocator(200)
majorFormatter = FormatStrFormatter('%d')
minorLocator = MultipleLocator(20)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.xaxis.set_major_locator(majorLocator)
ax.xaxis.set_major_formatter(majorFormatter)
ax.xaxis.set_minor_locator(minorLocator)
ax.xaxis.set_ticks_position('bottom')
ax.xaxis.grid(True,which='minor')
ax.yaxis.grid(True)
plt.plot(timemat,fildata)
plt.xlabel(plotxlabel,fontsize=14)
plt.ylabel(plotylabel,fontsize=14)
plt.title(plottitle,fontsize=16)
fig.savefig(plotsavetitle,dpi=600)
【问题讨论】:
-
这是很多数据,考虑到 1600x1200 将“只有”1,920,000 个像素。你想制作什么样的情节?如果它是一个直方图,你可以将它们装箱,一条线可以被二次采样..
-
它是来自加速度计的数据,以 1500 Hz 采样以捕获高频冲击。我正在尝试制作简单的电压(V)与时间图。因此,首先我为时间数组生成类似数量的数据,并根据时间绘制信号。是的,它很大,但我相信它会变得更大,因为我们正在进行 2 到 4 小时的实验。请告诉我如何对一条线进行二次采样...非常感谢!
-
在输入上使用切片(在两个轴上)。例如,要选择数组
x的每 10 个元素,您可以使用x[::10] -
但是,有没有办法在不抽取任何数据的情况下绘制数据?
-
将其拆分为单独的图。除非图像真的很宽,否则您无法将那么多信息放入图像中。但是,鉴于您所说的高频冲击,也许对您更有帮助的可能是查看频谱的高频部分(FFT)而不是时域。
标签: python python-3.x matplotlib