Skip to content
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

ENH: allow ranges to be set on Styler .bar() #21526

Open
psychemedia opened this issue Jun 18, 2018 · 5 comments

Comments

Projects
None yet
5 participants
@psychemedia
Copy link

commented Jun 18, 2018

When generating in table bar charts using the Styler .bar():

  • extreme outliers in a column mask differences in other values;
  • comparisons across columns are not supported.

One solution would be to allow the setting of explicit bounds on the range of values used to limit the bar extrema using explicit values rather than s.min() and s.max().

Cell values exceeding the range limits could be extending to the cell edge / maximum limit value and then coloured with an "overflow" colour.

@WillAyd

This comment has been minimized.

Copy link
Member

commented Jun 18, 2018

Please be sure to checkout out the contributing guide on how to open bug reports:

https://pandas.pydata.org/pandas-docs/stable/contributing.html#bug-reports-and-enhancement-requests

This is missing version information and a minimally reproducible example. You can find more information on how to construct one of those here:

http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports

It's difficult to infer from what you have here alone exactly what the problem is and what you are looking for, so try going through the above to see if we can get to something more explicit

@psychemedia

This comment has been minimized.

Copy link
Author

commented Jun 18, 2018

Pandas version 0.23.0

In the following example a dataframe is created with a column containing two outlier values (x1) and two columns where it would be useful to depict and compare the values over the same range even though in this example the ranges differ:

import pandas as pd
import numpy as np

df=pd.DataFrame({'x1':list(np.random.randint(-10,10,size=10))+[-500,1000, -1000],
               'y1':list(np.random.randint(-5,5,size=13)), 'y2':list(np.random.randint(-2,3,size=13)) })

df.style.bar( align='zero', color=[ '#5fba7d','#d65f5f'])

In column x1, the outlier values set the max/min range values used to display the styled bar and the variation in the non-outlier values is masked. It would be useful to be able to set max / min limits to so that variation in the non-outlier values can be depicted. For example, setting min,max=(-10,10) and then colouring squares with outlier values [-500,1000, -1000] differently to show they are outside the depicted range.

For columns y1 and y2, it may be desired to display the bars over the same range, for example min,max=(-5,5) so that a direct visual comparison can be made across columns y1 and y2.

@soxofaan

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2018

FYI: pull request #21548 now includes support for vmin and vmax arguments in Styler.bar

soxofaan added a commit to soxofaan/pandas that referenced this issue Jul 11, 2018

soxofaan added a commit to soxofaan/pandas that referenced this issue Jul 12, 2018

soxofaan added a commit to soxofaan/pandas that referenced this issue Jul 26, 2018

soxofaan added a commit to soxofaan/pandas that referenced this issue Aug 14, 2018

soxofaan added a commit to soxofaan/pandas that referenced this issue Aug 21, 2018

TomAugspurger added a commit that referenced this issue Aug 30, 2018

ENH? Styler.bar support for axis=None
* ENH: Styler.bar: add support for tablewise application with axis=None #21548

- eliminate code duplication related to style.bar with different align modes
- add support for axis=None
- fix minor bug with align 'zero' and width < 100
- make generated CSS gradients more compact

* ENH: Styler.bar: add support for vmin/vmax #21526

* ENH: Styler.bar: properly support NaNs

* ENH: Styler.bar: docstring improvements

Sup3rGeo added a commit to Sup3rGeo/pandas that referenced this issue Oct 1, 2018

ENH? Styler.bar support for axis=None
* ENH: Styler.bar: add support for tablewise application with axis=None pandas-dev#21548

- eliminate code duplication related to style.bar with different align modes
- add support for axis=None
- fix minor bug with align 'zero' and width < 100
- make generated CSS gradients more compact

* ENH: Styler.bar: add support for vmin/vmax pandas-dev#21526

* ENH: Styler.bar: properly support NaNs

* ENH: Styler.bar: docstring improvements
@domoritz

This comment has been minimized.

Copy link

commented Oct 29, 2018

Is there a way to set the color range in the currently released pandas version?

@soxofaan

This comment has been minimized.

Copy link
Contributor

commented Oct 29, 2018

@domoritz there is a color argument, see http://pandas.pydata.org/pandas-docs/stable/generated/pandas.io.formats.style.Styler.bar.html . Also: please specify which pandas version you are using ("currently released" doesn't say a lot).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.