Skip to content

ENH: background_gradient accepts a normalization parameter #56756

@rcyost

Description

@rcyost

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

its really hard to normalize df style background gradients like other colormap accepting attributes

Feature Description

Parameters:

norm

cmapstr or colormap
Matplotlib colormap.

lowfloat
Compress the color range at the low end. This is a multiple of the data range to extend below the minimum; good values usually in [0, 1], defaults to 0.

highfloat
Compress the color range at the high end. This is a multiple of the data range to extend above the maximum; good values usually in [0, 1], defaults to 0.

axis{0, 1, “index”, “columns”, None}, default 0
Apply to each column (axis=0 or 'index'), to each row (axis=1 or 'columns'), or to the entire DataFrame at once with axis=None.

subsetlabel, array-like, IndexSlice, optional
A valid 2d input to DataFrame.loc[], or, in the case of a 1d input or single key, to DataFrame.loc[:, ] where the columns are prioritised, to limit data to before applying the function.

text_color_thresholdfloat or int
Luminance threshold for determining text color in [0, 1]. Facilitates text

visibility across varying background colors. All text is dark if 0, and

light if 1, defaults to 0.408.

vminfloat, optional
Minimum data value that corresponds to colormap minimum value. If not specified the minimum value of the data (or gmap) will be used.

vmaxfloat, optional
Maximum data value that corresponds to colormap maximum value. If not specified the maximum value of the data (or gmap) will be used.

gmaparray-like, optional
Gradient map for determining the background colors. If not supplied will use the underlying data from rows, columns or frame. If given as an ndarray or list-like must be an identical shape to the underlying data considering axis and subset. If given as DataFrame or Series must have same index and column labels considering axis and subset. If supplied, vmin and vmax should be given relative to this gradient map.

Alternative Solutions

add a parameter that takes a norm object

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions