-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
background_gradient vmin and vmax #12145
Comments
That's what I wanted initially as well, but didn't have time to do it properly before the last release. I wonder if we should just require seaborn for those parameters, and use its heuristics for determining a good colormap and handling vmin/vmax. |
Hi, I have some feedback which IIUC is related to what @alimanfoo is saying. The
It can be very misleading if the color scale is only applied to each column separately - particulary when I specify a subset of columns (which represent the same measure) I expected them to be represented with the same color scale by default. I tried to set |
Couldn't agree more with @mpschr --- |
@alimanfoo I'm not sure it applies directly to your problem, but to get the equivalent of vmin/vmax for the colormap, I do the following: # given df, cmap, vmin, vmax:
df_data = df.copy()
df = df.clip(vmin, vmax)
df = df.style.background_gradient(cmap=cmap)
df.data = df_data |
FYI: |
Resolve pandas-dev#12145 and pandas-dev#28869 For `vmin` and `vmax` use the same implementation in `Styler.bar` For dtype `Int64` issue, deprecated `.values` and use `.to_numpy` instead Here explicitly assign the dtype to float since we are doing normalize
…29245) * ENH: Styler.background_gradient to accept vmin vmax and dtype Int64 Resolve #12145 and #28869 For `vmin` and `vmax` use the same implementation in `Styler.bar` For dtype `Int64` issue, deprecated `.values` and use `.to_numpy` instead Here explicitly assign the dtype to float since we are doing normalize
Thanks everyone, much appreciated. |
…andas-dev#29245) * ENH: Styler.background_gradient to accept vmin vmax and dtype Int64 Resolve pandas-dev#12145 and pandas-dev#28869 For `vmin` and `vmax` use the same implementation in `Styler.bar` For dtype `Int64` issue, deprecated `.values` and use `.to_numpy` instead Here explicitly assign the dtype to float since we are doing normalize
…andas-dev#29245) * ENH: Styler.background_gradient to accept vmin vmax and dtype Int64 Resolve pandas-dev#12145 and pandas-dev#28869 For `vmin` and `vmax` use the same implementation in `Styler.bar` For dtype `Int64` issue, deprecated `.values` and use `.to_numpy` instead Here explicitly assign the dtype to float since we are doing normalize
…andas-dev#29245) * ENH: Styler.background_gradient to accept vmin vmax and dtype Int64 Resolve pandas-dev#12145 and pandas-dev#28869 For `vmin` and `vmax` use the same implementation in `Styler.bar` For dtype `Int64` issue, deprecated `.values` and use `.to_numpy` instead Here explicitly assign the dtype to float since we are doing normalize
Working with the new style API, I would like to turn several columns of a dataframe into something like a heatmap. I would like to use the same range for all columns in the subset, i.e., the colour map should take a minimum and maximum value I specify, regardless of what actual range each column has. Currently using the "min" and "max" this is not intuitive. I would much prefer to be able to specify explicit vmin and vmax values, analogous to the seaborn.heatmap function.
Thanks for the style API, extremely useful.
The text was updated successfully, but these errors were encountered: