-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: Only render single patch for scatter #7214
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are parts of matplotlib I just don't understand…
Sorry, my review isn't very useful: I am just trying to understand what's going on: I don't see how your patch is fixing the bug.
@@ -316,7 +316,7 @@ def get_sizes(self, legend, orig_handle, | |||
numpoints = self.get_numpoints(legend) | |||
if numpoints < 4: | |||
sizes = [.5 * (size_max + size_min), size_max, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could easily be unit tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible that this is the only change that really matters here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the more reason to unit test it, no?
It is a very easy unit test to check that the return lengths is equal to numpoints.
Also, my two cents is that I would much prefer the returned size to be sorted (only matters for numpoints == 3)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also vote for drawing the markers in increasing size. (This also makes the code simpler; now only numpoints=1 needs to be special-cased.)
@@ -400,7 +400,7 @@ def _iter_collection_uses_per_path(self, paths, all_transforms, | |||
if Npaths == 0 or (len(facecolors) == 0 and len(edgecolors) == 0): | |||
return 0 | |||
Npath_ids = max(Npaths, len(all_transforms)) | |||
N = max(Npath_ids, len(offsets)) | |||
N = max(Npaths, len(offsets)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken, this function is only used to compute whether or not to do an optimization. Hence, over estimating the number of paths drawn is not that important and I am assuming that this as no impact on the bug you are fixing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Also, if we put a fix there, I'd also just replace the next line by return int(np.ceil(N / Npath_ids))
which is much clearer in intent.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this even needed to fix the problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just an optimization (see docstring) and it doesn't even really matter whether this is correct or not (modulo an unnecessary increase in the size of the svg).
The difference in the test_legend png baseline plots is imperceptible by eye. Perhaps it would be worthwhile to modify that test to include the alpha and size variation from the scatter example that showed the problem in the first place. |
@NelleV I figured it out: that's because I used |
Interesting. Maybe the code should raise a warning? |
@NelleV that's a bit a side issue but anyways... Currently
(resulting plot is empty). If anything this should raise a ValueError (and whether to error on zero sizes or not is a separate issue). |
2830f11
to
524cfbd
Compare
The failure seems unrelated, but is consistently here… |
.... and only on pytest. When in doubt |
524cfbd
to
25fbe8f
Compare
Thanks @tacaswell ! |
FIX: Only render single patch for scatter
backported to v2.x as 568b523 |
Alternative to #6883