0

I am utilizing the pcolormesh function in Matplotlib to plot a series of gridded data (in parallel) across multiple map domains. The code snippet relevant to this question is as follows:

im = ax2.pcolormesh(xgrid, ygrid, data.variable.data[0], cmap=cmap, norm=norm, alpha=0.90, facecolor=None)
Where: xgrid = array of longitude points, ygrid = array of latitude points, data.variable.data[0] = array of corresponding data values, cmap = defined colormap, & norm = defined value normalization

Consider the following image generated from the provided code:

Generated Image

The undesired result I've found in the image above is what appears to be outlines around each grid square, or perhaps better described as patchwork that stands out slightly as the mesh alpha is reduced below 1.

I've set facecolor=None assuming that would remove these outlines, to no avail. What additions or corrections can I make to remove this feature?

TornadoEric
  • 399
  • 3
  • 16
  • 1
    Looks like there may be artifacts developing due to interactions between alpha and anti-aliasing? Set the alpha back to 1 and change the colors if need be, do you need alpha < 1? – Pete Jan 09 '23 at 22:26
  • 1
    Thanks for the tip @Pete: I applied the alpha change to 1 and that artifact does indeed disappear. I haven't encountered this issue before, are those outlines normal behavior and I've missed this until now? – TornadoEric Jan 09 '23 at 22:38
  • It's normal in the sense that alpha and anti-aliasing can generate such artifacts if not carefully applied, possibly there is a slight bug in matplotlib in the area. The underlying library that draws the elements (cairo possibly) may require a half pixel offset to avoid this, for instance. Not sure, no idea about the internals of matplotlib, and its been a long time since I've used it. – Pete Jan 10 '23 at 20:44

0 Answers0