Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么matplotlib图像大小必须为<;=2^16?_Python_Image_Matplotlib_Python Imaging Library - Fatal编程技术网

Python 为什么matplotlib图像大小必须为<;=2^16?

Python 为什么matplotlib图像大小必须为<;=2^16?,python,image,matplotlib,python-imaging-library,Python,Image,Matplotlib,Python Imaging Library,尝试将超大数组(~5 000 000,200)保存为图像,但matplotlib raiseValueError:4741988x210像素的图像大小太大。在每个方向上必须小于2^16 代码如下: from matplotlib.ticker import FixedLocator, FixedFormatter fig = plt.figure(figsize = (4741988,210), frameon=False, dpi = 1) ax = fig.gca() ax.imshow(

尝试将超大数组(~5 000 000,200)保存为图像,但matplotlib raise
ValueError:4741988x210像素的图像大小太大。在每个方向上必须小于2^16

代码如下:

from matplotlib.ticker import FixedLocator, FixedFormatter
fig = plt.figure(figsize = (4741988,210), frameon=False, dpi = 1)

ax = fig.gca()
ax.imshow(final_image_train)

y_formatter = FixedFormatter(np.arange(start_len_train,end_len_train+1,1))
y_locator = FixedLocator(np.linspace(0, final_image_train.shape[0], end_len_train - start_len_train))

ax.yaxis.set_major_formatter(y_formatter)
ax.yaxis.set_major_locator(y_locator)

ax.tick_params(axis="y", labelsize=1, length = 2, width = 0.1, grid_linewidth = 0.01, pad = 0.1)
plt.xticks([])

ax.patch.set_visible(False)
plt.box(on=None)

plt.savefig('test.svg', bbox_inches='tight', pad_inches = 0)
所以我想知道有没有办法以高质量保存这样的图像?为什么mpl将最大大小限制为2^16。我的机器配备32gb内存。 除了matplotlib,我们还有其他软件包来处理如此大的阵列吗?
如有任何建议,我们将不胜感激。

您是否尝试过
cv2.imwrite()
,是否有机会使用cv2软件包使用我设置的轴设置保存图像(在上面的代码中)?我认为它只处理没有轴的纯图像和e.t.cusing
matplotlib
尝试避免打印图像,删除
plt.figure()
ax.imshow()