-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Masked pcolormesh is not tested correctly #8802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
#14414 added alpha channel support for triangle meshes in the pdf backend, but I think the question remains how masked results pcolormesh results should look. With flat shading the quads with masked vertices are removed but with Gouraud shading the color is interpolated between the data color and the "bad value" color, which defaults to (0,0,0,0) (black but transparent) so the intermediate colors are a blurry grey. I can't think of an application where someone would want the latter result, but as noted in the #14414 discussion, we don't actually know who's using this feature. |
I think that adding Gouraud shading to pcolormesh is fundamentally confusing; I would prefer that it be broken out into its own function. pcolor, pcolormesh, and pcolorfast are all for coloring quadrilaterals with specified boundaries; the colors are not specified at vertices but for regions. Vertices are not masked; quadrilaterals are. Gouraud shading, with colors specified at vertices, is different. It is more closely related to an image than to a pcolormesh. |
I feel I should chime in here since I am actually one of the people using these features. Recently, I've been dealing with a problem with pcolormesh when dealing with masked arrays or transparency. I think it has to do with the interpolation issues mentioned here, but not sure - maybe one of you all can provide some guidance. I recently posted a question on stackoverflow about this issue, with no response so far. Basically, when using pcolormesh with non-masked arrays or without a transparent colormap, the results are normal. When I plot masked arrays or have transparent colormaps, the plot becomes a bit more noisy and pixelated. I think it comes down to how the colors are interpolated from nan or transparent values (effectively treated the same by matplotlib). Here are some examples in addition to the stackoverflow article: First, just a plot of radar reflectivity - no nans and no transparency below 10 on the colormap. This behaves as expected. My ultimate goal was to produce a plot of radar reflectivity with precip type, which involves 3 separate arrays. To get it all on the same map, I first plot the regular radar (rain), then plot mix, and snow last. To prevent the latter two pcolormesh calls wiping out all the colors from the first, I either have to mask non-frozen precip areas or make the colormaps transparent in the "white" regions. You can see that this produces a more pixelated result in all areas of precipitation (most noticeable around the cutoff between green and white, and better seen in the stackoverflow post): I tried using gouraud shading to try to smooth out that mess, but it arguably produces a worse result - it has the weird grey/white boundaries described in this thread: I tried contourf, but like gourad shading, white boundaries remain. Ideally, there would be a smooth transition between the colors (like the pcolormesh plot, but not noisy). Also, contourf is too slow to be viable operationally, regardless. As a note, I need a solution that works with the Agg backend, as the scripts that make these images will be run via cron. I hope this is helpful, and I would be grateful for any solutions you all can provide! |
attn @WeatherGod @dopplershift |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
@anntzer added image tests for masked arrays, including quadmesh, in #23294 (
|
Closes matplotlib#8802. Fixes bug in backend_ps with zero-triangle gouraud inputs. Adds a test for this, and for valid gouraud cases with masking.
Closes matplotlib#8802. Fixes bug in backend_ps with zero-triangle gouraud inputs. Adds a test for this, and for valid gouraud cases with masking.
The
pcolormesh
test says that masked colour arrays are supported, but this maskedZm
variable is never used in the test. It appears that this has been the case since the test was added.I'm not sure exactly how the "correct" masked result should look, or I would update this myself. I hope one of the assignees should have some idea what to do here.
The text was updated successfully, but these errors were encountered: