Bug summary
Pixel widths appear irregularly in pcolor(x, y, z, rasterized=True), while x and y are regular. Using rasterized=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
import numpy as np
import matplotlib.pyplot as plt
x, 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
Bug summary
Pixel widths appear irregularly in
pcolor(x, y, z, rasterized=True), whilexandyare regular. Usingrasterized=Falseprovides 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
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
len(x)>100.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