Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: Irregular pixel widths in rasterized pcolor #23391

Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
@mschroen

Description

@mschroen
Issue body actions

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)
grafik

Expected outcome

rasterize=False (zoom-in to the lower left corner)
grafik

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.