| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Instead of the `self.nextFoo` counters. This way the various name sequences are defined closer together and it's impossible to forget to increment the counters.
draw_markers has been implemented, draw_line_collection was removed years ago but draw_quad_mesh could be implemented
and delete a useless comment
Sorry, something went wrong.
|
I agree that the grey looks wrong, but it could be a result of alpha blending with the white background. The alpha channel is effectively Gouraud interpolated between adjacent vertices, but I wonder if it should just be set to zero for the whole triangle where at least one vertex is masked out. I think that would correspond better to my intuition of how to show missing data, but I suppose in some use cases you might want to blend continuously with the background. The Agg results look like the renderer is doing linear interpolation for alpha inside the triangles but drawing the edges with opaque colors. |
Sorry, something went wrong.
|
Of course the grey color is because all of the RGBA channels are interpolated between the data color and zero. If you zoom in (on either the png or the pdf) the grey areas closest to the data are tinted with the data color. Here's a variant where the masked data is given another color: from matplotlib import cm, pyplot as plt
import numpy as np
import matplotlib
matplotlib.use('agg')
X, Y = np.meshgrid(
np.linspace(0, 10, 31),
np.linspace(0, 10, 8)
)
mesh = plt.pcolormesh(
X,
Y + 3*np.sin(X),
np.ma.masked_where(np.abs(Y-5)<2, X),
shading='gouraud',
cmap='jet',
)
mesh.get_cmap()._rgba_bad = (1.0, 0.0, 1.0, 0.3)
plt.savefig('example.png')
plt.savefig('example.pdf')png and pdf images: The question is, who are using pcolormesh and for what purpose, and what do they want to happen with missing data? With shading='flat' the missing quads are simply painted with the _rgba_bad color, and I think that would be the natural thing to do with Gouraud shading too, instead of interpolating the RGBA tuple between data values and _rgba_bad. |
Sorry, something went wrong.
|
Nice example. Your second version (the pdf) makes much more sense; the lines in the first plot (the png) can't be what anyone would want. |
Sorry, something went wrong.
|
A Github search isn't very enlightening. There are lots of copies of Matplotlib's _axes.py and quadmesh_demo.py around. Here are two interesting results I spotted: This one plots masked data with flat shading, then there's a cell with a gouraud plot but unfortunately it's not executed so we can't see what the result is. This one uses Gouraud shading for data where the missing parts are filled with zeros, then flat shading for a masked array. I suspect they wouldn't like the interpolated grey for the hole at the North Pole. |
Sorry, something went wrong.
|
To make typical masking work as one might expect with G shading, maybe it would be necessary to special-case alpha==0? If alpha == 0 on any vertex of a triangle, set alpha to zero for the entire triangle? |
Sorry, something went wrong.
|
mplcairo gets you |
Sorry, something went wrong.
|
Thank you. Well, it looks like mplcairo is not the solution. It isn't working at all for gouraud shading in the first pdf example (at least as rendered by preview). In the second example, it has the same sort of difference between png and pdf as backend_pdf. |
Sorry, something went wrong.
|
The first example works for me? |
Sorry, something went wrong.
|
I can't do anything about that :/ |
Sorry, something went wrong.
|
I'm on High Sierra and I see but the exported png is better:It's difficult to say if Preview is wrong or if there's a problem in the pdf file. None of the pdf reader applications I have tried give any error messages for subtly malformed files, so developing a pdf writer is a lot of guesswork. In any case, this PR adds alpha channel support to the draw_gouraud_triangles method in the pdf backend, which was missing before. I think the best place to fix the rest of pcolormesh is not in the backends but in the code that replaces missing data with zeros. |
Sorry, something went wrong.
and name the new members like _foo_seq to make them obviously private and to conform to PEP8
The pytest version requirement has changed.
Follow the PEP8 naming convention in the new members.
There was a problem hiding this comment.
I won't pretend to understand exactly what you have done, but the result looks great. Thank you!
Sorry, something went wrong.
| self.pageList = [] | ||
| self.fontObject = self.reserveObject('fonts') | ||
| self.alphaStateObject = self.reserveObject('extended graphics states') | ||
| self.extGStateObject = self.reserveObject('extended graphics states') |
There was a problem hiding this comment.
either keep the old name, or make the new name private, or at least document the change.
Sorry, something went wrong.
| def writeExtGSTates(self): | ||
| self.writeObject( | ||
| self.extGStateObject, | ||
| dict(itertools.chain( |
There was a problem hiding this comment.
(optionally)
dict([
*self.alphaStates.values(),
*self._soft_mask_states.values(),
])
Sorry, something went wrong.
And name its successor with an underline prefix.
There was a problem hiding this comment.
Anyone can merge after CI passes.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Suggestion for the request in #14327.
This is on top of #14412 (merged) and #14413.
PR Checklist