Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed as not planned
Labels
Description
Bug summary
Pixel widths appear irregularly inpcolor(x, y, z, rasterized=True)
, whilex
andy
are regular. Usingrasterized=False
provides correct (equal size) pixels, but saving the figure to.png
(instead of.pdf
) will show the same irregular pixel width bug.
It looks like a resampling bug, which messes up precise data visualization completely.
Code for reproduction
importnumpyasnpimportmatplotlib.pyplotaspltx,y=np.meshgrid(range(500),range(2))z= [np.tile([0,1],250),np.tile([0,1],250)]fig,ax=plt.subplots(1,1,figsize=(10,2))im=ax.pcolor(x,y,z,rasterized=True)ax.set_xticks(np.arange(0,40))fig.savefig('test.pdf')plt.show()
Actual outcome
In the resulting plot, some pixels are thinner, and some are thicker, than they should be.rasterize=True
(zoom-in to the lower left corner)
Expected outcome
rasterize=False
(zoom-in to the lower left corner)
Additional information
- This behaviour depends on the number of pixels plotted, for me it becomes visible above
len(x)>100
. - The spread between thicker and thinner lines increases with increasing size of the input array.
- If the view is reduced to a lower number of pixels (e.g.,
ax.set_xlim(0,10)
), the effect is no longer visible.
Operating system
Windows
Matplotlib Version
3.5.1
Matplotlib Backend
inline
Python version
3.9.6
Jupyter version
No response
Installation
pip