Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Plotly · Module

fig.update_coloraxes

fig.update_coloraxes updates shared continuous-color settings on a Plotly figure, including the colorscale, color domain, and colorbar. It accepts color-axis properties as keyword arguments.

How it works

Call this method on a figure to change properties of its shared color axis, including the palette, numeric color domain, automatic range behavior, and colorbar settings. Keyword arguments map to color-axis properties, while nested colorbar options can be supplied either as a dictionary or through flattened names such as colorbar_title_text.

Syntax

fig.update_coloraxes(arg=None, **kwargs)

Parameters

NameTypeDescription
autocolorscalebooleanWhether to use a default colorscale instead of the palette specified by colorscale.
cautobooleanWhether to compute the color domain from the input color data; defaults to false when cmin and cmax are set by the user.
cmaxnumberUpper bound of the color domain; cmin must also be set when this is provided.
colorscalecolorscaleColorscale mapping normalized values to supported color strings.
colorbardictNested colorbar properties, including title, ticks, position, and styling.

Returns

The page documents the update method and color-axis properties but does not specify a separate return value.

Key points

  • The figure method is called with keyword arguments that correspond to color-axis properties.
  • autocolorscale chooses between Plotly's default palette behavior and the explicitly selected colorscale.
  • cauto controls whether the color range is inferred from trace color data.
  • cmax sets the upper endpoint of the color domain.
  • colorscale changes the palette used for continuous color encoding.
  • The colorbar dtick setting is intended to be used together with tick0.

Common mistakes

  • When setting cmax, use the same units as the trace color values and set cmin too.
  • Custom colorscales must map normalized positions to supported color strings.

Example: Set a colorscale and color range

import plotly.express as px

fig = px.scatter(
    px.data.iris(),
    x="sepal_width",
    y="sepal_length",
    color="petal_length",
)
fig.update_coloraxes(colorscale="Viridis", cmin=1, cmax=7)
fig.show()

Creates a scatter plot with a continuous color dimension, then sets the shared color axis palette and numeric domain.

When to use it

Standardize color encoding

Apply one continuous palette across traces that use a shared color axis.

Fix the color domain

Make colors represent a stable numeric interval across figures or subplots.

Style the colorbar

Control the colorbar's ticks, title, position, and appearance.

Interview questions

QWhat does fig.update_coloraxes control?

It updates properties of the figure's coloraxis, which controls continuous color settings shared by applicable traces. Common uses include changing the colorscale, fixing cmin and cmax, and configuring the colorbar.

Follow-up: How would you prevent the range from being inferred from the data? Set cauto to false and provide the intended cmin and cmax values.

QHow do you define a custom colorscale?

The colorscale determines how normalized values map to colors. A custom scale is an array of position-color pairs, with positions normalized and colors expressed using supported CSS-like formats.

Follow-up: What must be true of a custom colorscale's positions? They should represent normalized values spanning the scale's domain.

QHow are fixed color ranges configured?

cmin and cmax define the lower and upper bounds of the color domain. If cmax is supplied, the documentation says cmin must also be supplied, and both should use the units of the trace color arrays.

Follow-up: What happens when cauto remains enabled? The color domain is computed from the input color data rather than only from manually specified bounds.

  • layout.coloraxis
  • colorbar
  • colorscale
  • cauto
  • cmin
  • cmax
  • fig.update_traces

Source: Layout.coloraxis in Python - Plotly. Checked 2026-10-15.