-
Notifications
You must be signed in to change notification settings - Fork 153
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
Force line collection to always respect colormap #2299
Conversation
Codecov ReportBase: 88.09% // Head: 88.06% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #2299 +/- ##
==========================================
- Coverage 88.09% 88.06% -0.04%
==========================================
Files 247 247
Lines 23563 23476 -87
==========================================
- Hits 20758 20673 -85
+ Misses 2805 2803 -2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Looks good, can you add a changelog entry? (in the 1.6.0 section - you might need to rebase) |
913c806
to
f715379
Compare
@astrofrog I've rebased and added an entry in the changelog |
@Carifio24 - could you rebase this? |
f715379
to
ec0e3bb
Compare
@astrofrog I've just rebased |
…ne edges will always be colormapped.
ec0e3bb
to
2d27081
Compare
Just rebasing to resolve a conflict |
2d27081
to
6b25b1b
Compare
The scatter viewer currently has a bug (noticed by @victoriaono) where the line collection that connects points will only obey the selected colormap if that colormap was set before a line was first displayed on the viewer. Additionally, if a fixed color is set after the line displays, subsequent colormap usage will not be respected. See the video below for an example.
scatter-line-bug-2022-05-21_18.14.18.mp4
This PR creates consistent behavior by calling
set_color(None)
inside the line collection'sset_linearcolor
method. The reason for this has to do with how the behavior is implemented insidematplotlib
. Whenever the colormap mode is Fixed, we callset_linearcolor
withcolor=self.state.color
here. This call's the artist'sset_color
method, which ultimately callsset_facecolor
and sets_original_facecolor
to that color.However, when
cmap_mode
is set toLinear
, we callset_mpl_artist_cmap
here without a color argument, which doesn't doesn't callset_color
, and so_original_facecolor
remains as the solid color. The artist's_edge_is_mapped
attribute is set to false if_original_edgecolor
has a color value, which means that the edgecolors of the artist are set to the original edgecolor, rather than the colormapped colors. This is why things work if we set the colormap before the line first displays - we haven't made a call to the line collection'sset_color
method yet, so_original_facecolor
is stillNone
. By callingset_color(None)
, we reset_original_facecolor
toNone
, allowing the line collection edges to be colormapped.