python
runtime_error
ai_generated
true
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%Fix Rate
86%Confidence
0Evidence
2024-11-28First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
Saving a figure with figsize*dpi exceeding 65535 pixels in either dimension, which exceeds the PNG/JPEG limits enforced by the backend.
generic中文
保存图形时 figsize*dpi 在任一维度超过 65535 像素,超出后端对 PNG/JPEG 的限制。
Workarounds
-
95% success
fig.set_size_inches(20, 16) fig.savefig('out.png', dpi=150) # 3000x2400 px -
92% success
fig.savefig('out.pdf') # no pixel limit for vector backends
Dead Ends
Common approaches that don't work:
-
92% fail
Higher dpi worsens the pixel count and triggers the same limit.
-
85% fail
'raw' is not a valid format for savefig; the size limit still applies to raster backends.