-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: don't plot colorbar if c is column containing colors #34344
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
Changes from 1 commit
c05b255
6562795
e70c650
0f2c00a
4a60600
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -951,9 +951,6 @@ def _make_plot(self): | |
|
||
c_is_column = is_hashable(c) and c in self.data.columns | ||
|
||
# plot a colorbar only if a colormap is provided or necessary | ||
cb = self.kwds.pop("colorbar", self.colormap or c_is_column) | ||
|
||
# pandas uses colormap, matplotlib uses cmap. | ||
cmap = self.colormap or "Greys" | ||
cmap = self.plt.cm.get_cmap(cmap) | ||
|
@@ -969,6 +966,16 @@ def _make_plot(self): | |
else: | ||
c_values = c | ||
|
||
# plot a colorbar only if a colormap is provided or necessary | ||
from matplotlib.colors import is_color_like | ||
|
||
c_is_column_not_containing_colors = c_is_column and not all( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe currently we should only consider if because your other PR are still under development, and seems no concrete conclusion on how we will show categorical/color-like in colorbar/legend, so now only having numeric values on colorbar seems most reasonable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, good point - thanks for your review, @charlesdong1991 ! |
||
np.vectorize(is_color_like)(c_values) | ||
) | ||
cb = self.kwds.pop( | ||
"colorbar", self.colormap or c_is_column_not_containing_colors | ||
) | ||
|
||
if self.legend and hasattr(self, "label"): | ||
label = self.label | ||
else: | ||
|
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.
maybe remove this line and add a more descriptive comment for the next line (
c_is_column_not_containing_colors
)? this comment does not seem to add too much value to help others understand?