python
runtime_error
ai_generated
true
RuntimeError: 图像尺寸 100000x80000 像素过大。每个方向必须小于 2^16。
RuntimeError: In set_size: Could not set the fontsize (or) Image size of 100000x80000 pixels is too large. It must be less than 2^16 in each direction.
ID: python/matplotlib-figure-too-large
80%修复率
86%置信度
0证据数
2024-11-28首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
保存图形时 figsize*dpi 在任一维度超过 65535 像素,超出后端对 PNG/JPEG 的限制。
English
Saving a figure with figsize*dpi exceeding 65535 pixels in either dimension, which exceeds the PNG/JPEG limits enforced by the backend.
解决方案
-
95% 成功率
fig.set_size_inches(20, 16) fig.savefig('out.png', dpi=150) # 3000x2400 px -
92% 成功率
fig.savefig('out.pdf') # no pixel limit for vector backends
无效尝试
常见但无效的做法:
-
92% 失败
Higher dpi worsens the pixel count and triggers the same limit.
-
85% 失败
'raw' is not a valid format for savefig; the size limit still applies to raster backends.