Skip to content

Scales API Reference

Scales control how data values are mapped to visual properties like position, color, size, and shape.

Continuous Axis Scales

ggplotly.scales.scale_x_continuous.scale_x_continuous

Bases: Scale

Continuous position scale for the x-axis.

Position scales control how data values are mapped to visual positions. This scale handles continuous numeric data on the x-axis.

Aesthetic: x

Parameters:

Name Type Description Default
name str

Label for the x-axis.

None
limits tuple

Two-element tuple (min, max) specifying the axis limits. Values outside limits will be removed (use oob to change this behavior).

None
breaks list

List of positions at which to place major tick marks.

None
minor_breaks list

List of positions for minor tick marks.

None
n_breaks int

Approximate number of breaks to generate automatically. Default is 5. Ignored if breaks is provided.

5
labels list

List of labels corresponding to the breaks. Can also be a callable that takes breaks and returns labels.

None
expand tuple

Expansion to add around the data range. Default is (0.05, 0) meaning 5% expansion on each side, 0 additive. Format: (mult, add) or ((mult_low, mult_high), (add_low, add_high)).

(0.05, 0)
oob str

How to handle out-of-bounds values. Options: - 'censor': Replace with NA (default) - 'squish': Squish to range limits - 'keep': Keep all values

'censor'
na_value float

Value to use for missing data. Default is None.

None
trans str

Transformation to apply. Options: - 'identity': No transformation (default) - 'log', 'log10': Log base 10 - 'log2': Log base 2 - 'sqrt': Square root - 'reverse': Reverse the axis

None
position str

Position of the axis. Options: - 'bottom': Default for x-axis - 'top': Place axis at top

'bottom'
guide str

Type of guide. Default is 'axis'.

'axis'
format str

Format string for tick labels (e.g., '.2f', '%').

None

Examples:

>>> scale_x_continuous(name='Value')
>>> scale_x_continuous(limits=(0, 100), breaks=[0, 25, 50, 75, 100])
>>> scale_x_continuous(trans='log10')
>>> scale_x_continuous(expand=(0.1, 0))  # 10% expansion on each side
>>> scale_x_continuous(labels=lambda x: [f'${v}' for v in x])

__init__(name=None, limits=None, breaks=None, minor_breaks=None, n_breaks=5, labels=None, expand=(0.05, 0), oob='censor', na_value=None, trans=None, position='bottom', guide='axis', format=None)

Initialize the continuous x-axis scale.

Parameters:

Name Type Description Default
name str

Axis title.

None
limits tuple

Axis limits (min, max).

None
breaks list

Major tick positions.

None
minor_breaks list

Minor tick positions.

None
n_breaks int

Approximate number of auto-generated breaks. Default is 5.

5
labels list or callable

Labels for breaks.

None
expand tuple

Expansion factor (mult, add). Default is (0.05, 0).

(0.05, 0)
oob str

Out-of-bounds handling. Default is 'censor'.

'censor'
na_value float

Value for NA data.

None
trans str

Transformation ('log', 'sqrt', 'reverse', etc.).

None
position str

Axis position ('bottom' or 'top'). Default is 'bottom'.

'bottom'
guide str

Guide type. Default is 'axis'.

'axis'
format str

Tick label format string.

None

apply(fig)

Apply the scale transformation to the x-axis of the figure.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

ggplotly.scales.scale_y_continuous.scale_y_continuous

Bases: Scale

__init__(name=None, limits=None, breaks=None, labels=None, trans=None)

Continuous position scale for the y-axis.

Parameters:

Name Type Description Default
name str

Label for the y-axis.

None
limits tuple

Two-element tuple specifying the axis limits (min, max).

None
breaks list

List of positions at which to place ticks.

None
labels list

List of labels corresponding to the breaks.

None
trans str

Transformation to apply ('log', 'sqrt', etc.).

None

apply(fig)

Apply the scale transformation to the y-axis of the figure.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

Logarithmic Scales

ggplotly.scales.scale_x_log10.scale_x_log10

Bases: Scale

Transform the x-axis to a log10 scale.

Aesthetic: x

This scale is useful for data that spans several orders of magnitude, making patterns in the lower range more visible.

Parameters:

Name Type Description Default
name str

Title for the x-axis.

None
breaks list

List of positions at which to place tick marks. Should be on the original (non-logged) scale.

None
minor_breaks list

List of positions for minor tick marks.

None
labels list

List of labels corresponding to the breaks. Can also be a callable that takes breaks and returns labels.

None
limits tuple

Two-element tuple (min, max) for axis limits. Should be on the original (non-logged) scale.

None
expand tuple

Expansion to add around the data range. Default is (0.05, 0).

(0.05, 0)
oob str

How to handle out-of-bounds values. Options: 'censor' (default), 'squish', 'keep'.

'censor'
na_value float

Value to use for NA/negative data.

None
guide str

Type of guide. Default is 'axis'.

'axis'

Examples:

>>> ggplot(df, aes(x='population', y='gdp')) + geom_point() + scale_x_log10()
>>> ggplot(df, aes(x='x', y='y')) + geom_point() + scale_x_log10(name='Value (log scale)')
>>> ggplot(df, aes(x='x', y='y')) + geom_point() + scale_x_log10(breaks=[1, 10, 100, 1000])

__init__(name=None, breaks=None, minor_breaks=None, labels=None, limits=None, expand=(0.05, 0), oob='censor', na_value=None, guide='axis')

Initialize the log10 x-axis scale.

Parameters:

Name Type Description Default
name str

Axis title.

None
breaks list

Tick positions (on original scale).

None
minor_breaks list

Minor tick positions.

None
labels list or callable

Labels for breaks.

None
limits tuple

Axis limits (on original scale).

None
expand tuple

Expansion factor (mult, add). Default is (0.05, 0).

(0.05, 0)
oob str

Out-of-bounds handling. Default is 'censor'.

'censor'
na_value float

Value for NA data.

None
guide str

Guide type. Default is 'axis'.

'axis'

apply(fig)

Apply log10 transformation to the x-axis.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

ggplotly.scales.scale_y_log10.scale_y_log10

Bases: Scale

Transform the y-axis to a log10 scale.

Aesthetic: y

This scale is useful for data that spans several orders of magnitude, making patterns in the lower range more visible.

Parameters:

Name Type Description Default
name str

Title for the y-axis.

None
breaks list

List of positions at which to place tick marks. Should be on the original (non-logged) scale.

None
minor_breaks list

List of positions for minor tick marks.

None
labels list

List of labels corresponding to the breaks. Can also be a callable that takes breaks and returns labels.

None
limits tuple

Two-element tuple (min, max) for axis limits. Should be on the original (non-logged) scale.

None
expand tuple

Expansion to add around the data range. Default is (0.05, 0).

(0.05, 0)
oob str

How to handle out-of-bounds values. Options: 'censor' (default), 'squish', 'keep'.

'censor'
na_value float

Value to use for NA/negative data.

None
guide str

Type of guide. Default is 'axis'.

'axis'

Examples:

>>> ggplot(df, aes(x='x', y='income')) + geom_point() + scale_y_log10()
>>> ggplot(df, aes(x='x', y='y')) + geom_point() + scale_y_log10(name='Income (log scale)')
>>> ggplot(df, aes(x='x', y='y')) + geom_point() + scale_y_log10(breaks=[1, 10, 100, 1000])

__init__(name=None, breaks=None, minor_breaks=None, labels=None, limits=None, expand=(0.05, 0), oob='censor', na_value=None, guide='axis')

Initialize the log10 y-axis scale.

Parameters:

Name Type Description Default
name str

Axis title.

None
breaks list

Tick positions (on original scale).

None
minor_breaks list

Minor tick positions.

None
labels list or callable

Labels for breaks.

None
limits tuple

Axis limits (on original scale).

None
expand tuple

Expansion factor (mult, add). Default is (0.05, 0).

(0.05, 0)
oob str

Out-of-bounds handling. Default is 'censor'.

'censor'
na_value float

Value for NA data.

None
guide str

Guide type. Default is 'axis'.

'axis'

apply(fig)

Apply log10 transformation to the y-axis.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

Reversed Scales

ggplotly.scales.scale_x_reverse.scale_x_reverse

Bases: Scale

Reverse the x-axis direction.

This scale reverses the x-axis so that larger values appear on the left and smaller values on the right. Useful for certain data presentations like depth charts, time running backwards, etc.

Aesthetic: x

Parameters:

Name Type Description Default
name str

Title for the x-axis.

None
breaks list

List of positions at which to place tick marks.

None
labels list

List of labels corresponding to the breaks. Can also be a callable that takes breaks and returns labels.

None
limits tuple

Two-element tuple (min, max) for axis limits. Note: min should still be less than max; the reversal happens automatically.

None
expand tuple

Expansion to add around the data range. Default is (0.05, 0).

(0.05, 0)

Examples:

>>> # Simple reversed x-axis
>>> ggplot(df, aes(x='x', y='y')) + geom_point() + scale_x_reverse()
>>> # Reversed x-axis with custom name
>>> ggplot(df, aes(x='depth', y='value')) + geom_line() + scale_x_reverse(name='Depth (m)')
>>> # Reversed with specific limits
>>> ggplot(df, aes(x='x', y='y')) + geom_point() + scale_x_reverse(limits=(0, 100))
See Also

scale_y_reverse: Reverse the y-axis scale_x_continuous: Continuous x-axis with trans='reverse' option

__init__(name=None, breaks=None, labels=None, limits=None, expand=(0.05, 0))

Initialize the reversed x-axis scale.

Parameters:

Name Type Description Default
name str

Axis title.

None
breaks list

Tick positions.

None
labels list or callable

Labels for breaks.

None
limits tuple

Axis limits (min, max).

None
expand tuple

Expansion factor (mult, add). Default is (0.05, 0).

(0.05, 0)

apply(fig)

Apply reversed transformation to the x-axis.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

ggplotly.scales.scale_y_reverse.scale_y_reverse

Bases: Scale

Reverse the y-axis direction.

This scale reverses the y-axis so that larger values appear at the bottom and smaller values at the top. Useful for certain data presentations like depth charts, rankings, or inverted coordinate systems.

Aesthetic: y

Parameters:

Name Type Description Default
name str

Title for the y-axis.

None
breaks list

List of positions at which to place tick marks.

None
labels list

List of labels corresponding to the breaks. Can also be a callable that takes breaks and returns labels.

None
limits tuple

Two-element tuple (min, max) for axis limits. Note: min should still be less than max; the reversal happens automatically.

None
expand tuple

Expansion to add around the data range. Default is (0.05, 0).

(0.05, 0)

Examples:

>>> # Simple reversed y-axis
>>> ggplot(df, aes(x='x', y='y')) + geom_point() + scale_y_reverse()
>>> # Reversed y-axis with custom name (e.g., for rankings)
>>> ggplot(df, aes(x='name', y='rank')) + geom_col() + scale_y_reverse(name='Rank')
>>> # Reversed with specific limits
>>> ggplot(df, aes(x='x', y='y')) + geom_point() + scale_y_reverse(limits=(0, 100))
>>> # Ocean depth chart (depth increases downward)
>>> ggplot(df, aes(x='distance', y='depth')) + geom_line() + scale_y_reverse()
See Also

scale_x_reverse: Reverse the x-axis scale_y_continuous: Continuous y-axis with trans='reverse' option

__init__(name=None, breaks=None, labels=None, limits=None, expand=(0.05, 0))

Initialize the reversed y-axis scale.

Parameters:

Name Type Description Default
name str

Axis title.

None
breaks list

Tick positions.

None
labels list or callable

Labels for breaks.

None
limits tuple

Axis limits (min, max).

None
expand tuple

Expansion factor (mult, add). Default is (0.05, 0).

(0.05, 0)

apply(fig)

Apply reversed transformation to the y-axis.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

Date and Time Scales

ggplotly.scales.scale_x_date.scale_x_date

Bases: Scale

Date scale for the x-axis.

__init__(name=None, limits=None, date_breaks=None, date_labels=None, breaks=None, labels=None, expand=None)

Format date values on the x-axis with customizable breaks and labels.

Similar to ggplot2's scale_x_date().

Parameters

name : str, optional Label for the x-axis. limits : tuple, optional Two-element tuple specifying date limits (min, max). Can be date strings ('2020-01-01') or datetime objects. date_breaks : str, optional Interval for tick marks. Examples: '1 day', '2 weeks', '1 month', '3 months', '1 year'. date_labels : str, optional strftime format string for tick labels. Examples: '%Y' (2020), '%b %Y' (Jan 2020), '%Y-%m-%d' (2020-01-15). breaks : list, optional Explicit list of date positions for ticks. labels : list, optional Explicit list of labels corresponding to breaks. expand : tuple, optional Expansion to add to limits (mult, add). Default (0.05, 0).

Examples

scale_x_date(date_breaks='1 month', date_labels='%b %Y') scale_x_date(limits=('2020-01-01', '2023-12-31'), date_breaks='6 months')

apply(fig)

Apply the date scale to the x-axis.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

ggplotly.scales.scale_x_date.scale_x_datetime

Bases: scale_x_date

Datetime scale for the x-axis with time component support.

__init__(name=None, limits=None, date_breaks=None, date_labels=None, breaks=None, labels=None, expand=None)

Format datetime values on the x-axis with time component support.

Like scale_x_date but for datetime data with time components. Supports finer granularity like hours, minutes, seconds.

Parameters

name : str, optional Label for the x-axis. limits : tuple, optional Two-element tuple specifying datetime limits. date_breaks : str, optional Interval for tick marks. Examples: '1 hour', '6 hours', '1 day', '1 week'. date_labels : str, optional strftime format string. Examples: '%Y-%m-%d %H:%M' (full), '%H:%M' (time only). breaks : list, optional Explicit list of datetime positions for ticks. labels : list, optional Explicit list of labels corresponding to breaks. expand : tuple, optional Expansion to add to limits.

Examples

scale_x_datetime(date_breaks='1 hour', date_labels='%H:%M') scale_x_datetime(date_breaks='1 day', date_labels='%b %d')

Interactive Scales

ggplotly.scales.scale_x_rangeslider.scale_x_rangeslider

Bases: Scale

Add an interactive range slider to the x-axis.

__init__(visible=True, bgcolor='white', bordercolor='#444', borderwidth=0, thickness=0.15, range=None, yaxis_rangemode='match')

Add an interactive range slider for zooming on the x-axis.

The range slider appears below the main plot and allows users to select a subset of the data to display. Particularly useful for time series data.

Parameters

visible : bool, default=True Whether the range slider is visible. bgcolor : str, default='white' Background color of the range slider. bordercolor : str, default='#444' Border color of the range slider. borderwidth : int, default=0 Border width in pixels. thickness : float, default=0.15 Height of the range slider as a fraction of the plot (0-1). range : list, optional Initial visible range as [min, max]. If None, shows all data. yaxis_rangemode : str, default='match' How y-axis responds to range changes. Options:

- 'match': Y-axis range matches visible data (auto-scales)
- 'fixed': Y-axis range stays fixed
Examples

from ggplotly import ggplot, aes, geom_line, scale_x_rangeslider, data economics = data('economics')

Basic range slider on unemployment time series

ggplot(economics, aes(x='date', y='unemploy')) + geom_line() + scale_x_rangeslider()

Customize appearance

ggplot(economics, aes(x='date', y='unemploy')) + geom_line() + \ ... scale_x_rangeslider(bgcolor='lightgray', thickness=0.2)

Set initial visible range

ggplot(economics, aes(x='date', y='unemploy')) + geom_line() + \ ... scale_x_rangeslider(range=['1990-01-01', '2000-01-01'])

Fixed y-axis (won't auto-scale when zooming)

ggplot(economics, aes(x='date', y='unemploy')) + geom_line() + \ ... scale_x_rangeslider(yaxis_rangemode='fixed')

apply(fig)

Apply the range slider to the x-axis of the figure.

Parameters

fig : Figure Plotly figure object.

ggplotly.scales.scale_x_rangeselector.scale_x_rangeselector

Bases: Scale

Add range selector buttons to the x-axis.

__init__(buttons=None, visible=True, bgcolor='white', bordercolor='#444', borderwidth=0, font=None, x=None, y=None, xanchor='left', yanchor='bottom')

Add range selector buttons for quick time range selection.

Range selector buttons appear above the plot and allow users to quickly select predefined time ranges. Particularly useful for time series data with date/datetime x-axis.

Parameters

buttons : list of str or dict, optional List of button configurations. Can be string shortcuts or dicts:

String shortcuts: '1d', '7d', '1w', '2w', '1m', '3m', '6m', 'ytd', '1y', '2y', '5y', 'all'

Or dicts with:

- count (int): Number of steps
- label (str): Button label text
- step (str): Step unit ('month', 'year', 'day', 'hour', 'minute', 'second', 'all')
- stepmode (str): 'backward' (from end) or 'todate' (from start of period)

Default buttons: 1m, 6m, YTD, 1y, All

visible : bool, default=True Whether the range selector is visible. bgcolor : str, default='white' Background color of the selector. bordercolor : str, default='#444' Border color. borderwidth : int, default=0 Border width in pixels. font : dict, optional Font settings for button labels (size, color, family). x : float, optional X position of the selector (0-1, fraction of plot width). y : float, optional Y position of the selector (0-1, fraction of plot height). xanchor : str, default='left' Horizontal anchor ('left', 'center', 'right'). yanchor : str, default='bottom' Vertical anchor ('top', 'middle', 'bottom').

Examples

from ggplotly import ggplot, aes, geom_line, scale_x_rangeselector, scale_x_rangeslider, data economics = data('economics')

Basic range selector with default buttons (1m, 6m, YTD, 1y, All)

ggplot(economics, aes(x='date', y='unemploy')) + geom_line() + scale_x_rangeselector()

String shortcuts for common ranges

ggplot(economics, aes(x='date', y='unemploy')) + geom_line() + \ ... scale_x_rangeselector(buttons=['1m', '3m', '6m', 'ytd', '1y', 'all'])

Custom buttons for weekly and monthly views

ggplot(economics, aes(x='date', y='unemploy')) + geom_line() + \ ... scale_x_rangeselector(buttons=[ ... dict(count=7, label='1w', step='day', stepmode='backward'), ... dict(count=1, label='1m', step='month', stepmode='backward'), ... dict(step='all') ... ])

Combine with range slider for full interactive control

ggplot(economics, aes(x='date', y='unemploy')) + geom_line() + \ ... scale_x_rangeselector() + scale_x_rangeslider()

apply(fig)

Apply the range selector to the x-axis of the figure.

Parameters

fig : Figure Plotly figure object.

Color Scales

ggplotly.scales.scale_color_manual.scale_color_manual

Bases: Scale

__init__(values, name=None, breaks=None, labels=None)

Manually set colors for discrete color scales.

Parameters:

Name Type Description Default
values list or dict

A list or dictionary of colors.

required
name str

Legend title for the color scale.

None
breaks list

List of categories to appear in the legend.

None
labels list

List of labels corresponding to the breaks.

None

apply(fig)

Apply the manual color scale to the figure.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

ggplotly.scales.scale_color_gradient.scale_color_gradient

Bases: Scale

Create a two-color continuous gradient for the color aesthetic.

Aesthetic: color

Maps numeric values to a color gradient between two colors, useful for visualizing continuous variables.

Parameters:

Name Type Description Default
low str

Color for low values. Default is '#132B43' (dark blue).

'#132B43'
high str

Color for high values. Default is '#56B1F7' (light blue).

'#56B1F7'
name str

Title for the colorbar legend.

None
limits tuple

Two-element tuple (min, max) to set the range of values. Values outside this range will be clamped or treated as NA.

None
breaks list

List of values at which to show tick marks on colorbar.

None
labels list

Labels corresponding to breaks.

None
na_value str

Color for missing values. Default is 'grey50'.

'grey50'
guide str

Type of legend. 'colourbar' (default) or 'none'.

'colourbar'
aesthetics str

The aesthetic this scale applies to. Default is 'color'.

'color'

Examples:

>>> ggplot(df, aes(x='x', y='y', color='value')) + geom_point() + scale_color_gradient()
>>> ggplot(df, aes(x='x', y='y', color='value')) + geom_point() + scale_color_gradient(low='white', high='red')
>>> ggplot(df, aes(x='x', y='y', color='temp')) + geom_point() + scale_color_gradient(low='blue', high='orange', name='Temperature')

__init__(low='#132B43', high='#56B1F7', name=None, limits=None, breaks=None, labels=None, na_value='grey50', guide='colourbar', aesthetics='color')

Initialize the color gradient scale.

Parameters:

Name Type Description Default
low str

Color for low values. Default is '#132B43' (dark blue).

'#132B43'
high str

Color for high values. Default is '#56B1F7' (light blue).

'#56B1F7'
name str

Title for the colorbar legend.

None
limits tuple

Range of values (min, max).

None
breaks list

Values at which to show ticks.

None
labels list

Labels for the breaks.

None
na_value str

Color for NA values. Default is 'grey50'.

'grey50'
guide str

Legend type ('colourbar' or 'none'). Default is 'colourbar'.

'colourbar'
aesthetics str

The aesthetic this applies to. Default is 'color'.

'color'

apply(fig)

Apply the color gradient to markers and line segments in the figure.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

ggplotly.scales.scale_color_brewer.scale_color_brewer

Bases: Scale

Scale for mapping a categorical variable to a ColorBrewer palette.

__init__(type='seq', palette=1, direction=1)

Map a categorical variable to a ColorBrewer palette for color aesthetic.

Parameters

type : str, default='seq' Type of ColorBrewer palette: - 'seq': Sequential (ordered data) - default to match R - 'qual': Qualitative (categorical data) - 'div': Diverging (data with meaningful midpoint) palette : int or str, default=1 Index or name of the ColorBrewer palette. Can be: - An integer index (1-based, to match R) - A string name like 'Blues', 'Set1', 'RdBu' Common palette names: - Sequential: 'Blues', 'Greens', 'Reds', 'Oranges', 'Purples' - Qualitative: 'Set1', 'Set2', 'Set3', 'Pastel1', 'Dark2' - Diverging: 'RdBu', 'RdYlGn', 'BrBG', 'PiYG' direction : int, default=1 Direction of the palette. 1 for normal order, -1 for reversed.

Examples

scale_color_brewer() # default: sequential palette scale_color_brewer(type='qual', palette='Set1') scale_color_brewer(type='div', palette='RdBu') scale_color_brewer(palette='Blues', direction=-1) # reversed

apply(fig)

Apply the ColorBrewer color scale to the figure.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

get_legend_info()

Returns the legend information for the ColorBrewer scale.

Returns:

Name Type Description
dict

Legend information with the color mapping.

Fill Scales

ggplotly.scales.scale_fill_manual.scale_fill_manual

Bases: Scale

Scale for manually defining fill colors based on a categorical variable.

__init__(values, name=None, breaks=None, labels=None, na_value='gray', aesthetics='fill', guide='legend')

Manually define fill colors for each level of a categorical variable.

Parameters

values : dict or list Dictionary mapping each level of the categorical variable to a color, or a list of colors to be matched to categories in order. Keys are the category values, values are color specifications (names, hex codes, or rgb strings). name : str, optional Title for the legend. breaks : list, optional A list specifying which categories should appear in the legend. By default, all categories are shown. labels : list, optional A list of labels corresponding to the breaks, to be shown in the legend. Must be the same length as breaks if provided. na_value : str, default='gray' Color to use for missing values or categories not in the mapping. aesthetics : str, default='fill' The name of the aesthetic that this scale works with. guide : str, default='legend' Type of legend to use. Options: 'legend', 'none'.

Examples

scale_fill_manual({'A': 'red', 'B': 'blue', 'C': 'green'}) scale_fill_manual(['red', 'blue', 'green']) # colors assigned in order scale_fill_manual({'low': '#FEE08B', 'high': '#D73027'}, name='Level') scale_fill_manual({'A': 'red', 'B': 'blue'}, breaks=['A'], labels=['Category A'])

apply(fig)

Apply the manual fill scale to the figure.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

apply_scale(data, mapping)

Applies the manual fill scale to the data.

Parameters:

Name Type Description Default
data DataFrame

The input data containing the fill aesthetic.

required
mapping dict

The mapping of the categorical variable to the fill color.

required

Returns:

Name Type Description
DataFrame

Modified data with the manual fill color applied.

get_legend_info()

Returns the legend information (name and colors) for the manual fill scale.

Returns:

Name Type Description
dict

Legend information including name and color mappings.

ggplotly.scales.scale_fill_gradient.scale_fill_gradient

Bases: Scale

__init__(low='blue', high='red', name=None)

Create a continuous color gradient for fill aesthetics.

Parameters:

Name Type Description Default
low str

Color for low end of the gradient.

'blue'
high str

Color for high end of the gradient.

'red'
name str

Legend title for the fill scale.

None

apply(fig)

Apply the gradient fill scale to the figure.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

ggplotly.scales.scale_fill_brewer.scale_fill_brewer

Bases: Scale

Scale for mapping a categorical variable to a ColorBrewer palette for fill aesthetic.

__init__(type='seq', palette=1, direction=1)

Map a categorical variable to a ColorBrewer palette for fill aesthetic.

Parameters

type : str, default='seq' Type of ColorBrewer palette: - 'seq': Sequential (ordered data) - default to match R - 'qual': Qualitative (categorical data) - 'div': Diverging (data with meaningful midpoint) palette : int or str, default=1 Index or name of the ColorBrewer palette. Can be: - An integer index (1-based, to match R) - A string name like 'Blues', 'Set1', 'RdBu' Common palette names: - Sequential: 'Blues', 'Greens', 'Reds', 'Oranges', 'Purples' - Qualitative: 'Set1', 'Set2', 'Set3', 'Pastel1', 'Dark2' - Diverging: 'RdBu', 'RdYlGn', 'BrBG', 'PiYG' direction : int, default=1 Direction of the palette. 1 for normal order, -1 for reversed.

Examples

scale_fill_brewer() # default: sequential palette scale_fill_brewer(type='qual', palette='Set1') scale_fill_brewer(type='div', palette='RdBu') scale_fill_brewer(palette='Blues', direction=-1) # reversed

apply(fig)

Apply the ColorBrewer fill scale to the figure.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

get_legend_info()

Returns the legend information for the ColorBrewer scale.

Returns:

Name Type Description
dict

Legend information with the color mapping.

ggplotly.scales.scale_fill_viridis.scale_fill_viridis_c

Bases: Scale

__init__(option='viridis', name=None, direction=1)

Create a viridis continuous color scale for fill aesthetics.

Parameters:

Name Type Description Default
option str

Viridis palette option. One of: 'viridis', 'plasma', 'inferno', 'magma', 'cividis'

'viridis'
name str

Legend title for the fill scale.

None
direction int

Direction of the scale. 1 = normal, -1 = reversed.

1

apply(fig)

Apply the viridis fill scale to the figure.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

Other Scales

ggplotly.scales.scale_shape_manual.scale_shape_manual

Bases: Scale

__init__(values, name=None, breaks=None, labels=None)

Manually set shapes for discrete shape scales.

Parameters:

Name Type Description Default
values list or dict

A list or dictionary of Plotly marker symbols. If a list, shapes are assigned in order to categories. If a dict, keys should be category names and values should be Plotly symbols.

Common Plotly marker symbols: - 'circle', 'circle-open' - 'square', 'square-open' - 'diamond', 'diamond-open' - 'cross', 'x' - 'triangle-up', 'triangle-down', 'triangle-left', 'triangle-right' - 'star', 'star-open' - 'hexagon', 'hexagon-open' - 'pentagon', 'pentagon-open'

required
name str

Legend title for the shape scale.

None
breaks list

List of categories to appear in the legend.

None
labels list

List of labels corresponding to the breaks.

None

apply(fig)

Apply the manual shape scale to the figure.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required

ggplotly.scales.scale_size.scale_size

Bases: Scale

__init__(range=(2, 10), name=None)

Map a continuous variable to size aesthetic.

Parameters:

Name Type Description Default
range tuple

Two-element tuple specifying the min and max sizes.

(2, 10)
name str

Legend title for the size scale.

None

apply(fig)

Apply the size scale to the figure.

Parameters:

Name Type Description Default
fig Figure

Plotly figure object.

required