-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: Cannot use empty markers in scatter #24404
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
It's inconvenient, but not impossible. import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
x = np.arange(0, 10)
norm = plt.Normalize(0, 10)
cmap = mpl.colormaps['viridis']
cols = cmap(norm(x))
plt.scatter(x, x, facecolors='none', edgecolors=cols) |
Okay, rephrasing. Can we add your code to this function when |
A counter proposal would be that |
The default behavior is for the edge colors to follow the face color, layer with if you specify I have a worry about allowing the edge color to be mapped independently. On one hand you could say the face color and edge color must share the name norm and cmap, but if it will soon seem reasonable to relax that and let each have their own and new we will end up with a Sorry for rambling post. |
Oh, you are right - we indeed show and color the edges. In that case, I think I also agree with @Atcold that this is a "bug". Not sure how easy it is to fix without breaking the brittle dance we do here. |
Rather than having the edge colours ‘follow’ the face colours, we could have a mapping that is given to both the face and edge. If either face or edge colour is specified, that takes precedence over the mapping. |
That is reasonable, but there is a fair amount of book-keeping that will have to be reworked through (having the edge color follow the face it is easier in the case where you re-set the data / colormap / norm in that we only have to track it one place internally and the rest "just works"). Because scatter both takes mappings and fixed colors iirc using The work here is:
I think this is a good first issue because there is no API design here (that this should work seems non-controversial), but medium difficulty as it will require reading and understanding the internals of both the |
This should probably follow similar semantics to the pcolormesh face/edge discussion as well. xref to this comment which has a nice summary plot of the combinations: #18480 (comment) |
non-empty face colors and non-empty edge colors: import numpy as np x = np.arange(0, 10) empty face colors and non-empty edge colors: import numpy as np x = np.arange(0, 10) |
Hello, new contributor here. I'd like to outline my exploration/thoughts so far and invite discussion to clarify the source of the issue and what the change would look like. I took a look at the internals of the
Now, the proposed change seems to be related to the case where if edgecolors is None and not mpl.rcParams['_internal.classic_mode']:
edgecolors = mpl.rcParams['scatter.edgecolors'] A fix then would be to add another check prior to this conditional that checks for whether I suppose that alternatively, we could instead handle if plotnonfinite and colors is None:
c = np.ma.masked_invalid(c)
x, y, s, edgecolors, linewidths = \
cbook._combine_masks(x, y, s, edgecolors, linewidths) This would more closely resemble what is already being done when the As someone new to working with MatPlotLib, I am not sure about the ramifications of this change and would like some input from a more experienced contributor. Specifically, would this create any issues with the bookkeeping in |
I'm not sure what this message means. |
Assuming the first suggestion will fix this bug, the book-keeping in the collections sub-class for this issue would behave the same way as expected if these two test cases passed.
|
@Atcold can you please assign this issue to me,i want to work on this |
@Gairick52 we do not assign issues: https://matplotlib.org/stable/devel/contributing.html#issues-for-new-contributors |
Hello @Gairick52 - as pointed above we don't assign issues. As long as there is no Pull Request associated with the issue, you can feel free to work on it. Please take a look at our Contributing guide and if you have specific questions you can also join our gitter room or one of our monthly New contributor meetings (on Zoom). Cheers! |
Sorry but how does #29130 close this? Nothing in this issue is about problems using |
Sorry, GitHub auto close behavior, should have double checked what it was auto closing. |
Bug summary
I'd like to have a scatter plot with empty
'o'
markers (just the edge).This seems impossible.
Code for reproduction
Actual outcome
Expected outcome
Empty markers.
Matplotlib Version
3.5.1
The text was updated successfully, but these errors were encountered: