-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[ENH]: scalermappable bar #26312
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
Gradient barsNote that #23265 is asking for "draw 3d bars gradient", which is the second example in https://de.mathworks.com/help/matlab/creating_plots/color-3-d-bars-by-height-1.html. Even with a scalarmappable bar, we'll not be able to support this. One could achive this with a value-scaled variation of https://matplotlib.org/stable/gallery/lines_bars_and_markers/gradient_bar.html#sphx-glr-gallery-lines-bars-and-markers-gradient-bar-py. But I think we're far from internal code structures or an API needed to include this as a builtin feature. For now, I'd say, this are out of scope. Color-coded barsThis is fundamentally reasonable, even though #26310 is not making a good case for it. We have basically two cases: 1. discrete colors that show up in the legend.Examples:
These are already handled via https://matplotlib.org/stable/gallery/lines_bars_and_markers/bar_colors.html 2. Continuous colors.I've found two classes of examples:
This needs a colorbar as reference and is the only case possibly warranting an extension of our API. Be aware though that bars have color, edgecolor and ecolor (errorbars). And that we need a conscious decision how to handle them (likely only provide colormapping for the face color).
rather replace |
Uh oh!
There was an error while loading. Please reload this page.
Problem
Coloring the bars in the bar chart based on some value isn't uncommon (#23265, #26310) and
colors=cmap(norm(values))
is serviceable but it'd be nice if folks could directly set the cmap, norm, and data separately-especially for legend and colorbar creation.Proposed solution
While it has it's problems, scatter has an API for how to manage colormap/norm or colors for discrete markers, so I think it would stay consistent if the scatter API for colors could be ported to bars. Could then probably adapt scatter.legend_elements implementation to auto generate legends from the colors.
ETA: If we did this, it'd probably also be a good reason to implement #7383
The text was updated successfully, but these errors were encountered: