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

Plotly · Module

fig.update_yaxes

Updates one or more y-axes on a Plotly graph-object Figure. Use keyword arguments to set layout.yaxis properties such as titles, ranges, grid visibility, and tick formatting.

How it works

Call this method on a graph-object Figure to modify properties of one or more y-axes. Supply axis properties as keyword arguments; for figures with multiple axes, selector arguments can target which axes are changed.

Syntax

fig.update_yaxes(**kwargs)

Parameters

NameTypeDescription
**kwargskeyword argumentsAxis layout properties supplied as keyword arguments, including title_text, range, showgrid, visible, position, and other layout.yaxis attributes.

Returns

A Plotly graph-object Figure with the requested y-axis properties updated.

Key points

  • Use range with two values to control the displayed lower and upper bounds.
  • The position property places a free y-axis using normalized plot coordinates.
  • autoshift can reposition an axis to reduce overlap among axes sharing an overlaying value.

Common mistakes

  • For logarithmic axes, provide range endpoints in logarithmic coordinates rather than the original data values.
  • The position setting does nothing unless the y-axis is independently anchored.
  • Setting visible to false hides the visual axis but does not remove interactive dragging.

Example: Configure a y-axis

import plotly.express as px

fig = px.scatter(x=[1, 2, 3], y=[10, 20, 15])
fig.update_yaxes(title_text="Value", range=[0, 25], showgrid=True)
fig.show()

Creates a scatter plot and changes several properties of its y-axis.

When to use it

Label and style an axis

Improve readability of a chart by setting a descriptive y-axis title and controlling gridlines.

Control displayed range

Focus a chart on a meaningful interval by explicitly setting its y-axis bounds.

Customize subplot axes

Configure faceted or multi-axis figures by applying consistent y-axis settings across selected axes.

Interview questions

QWhat does fig.update_yaxes do?

It updates nested properties on one or more y-axes of a graph-object Figure. Keyword arguments correspond to layout.yaxis properties, such as title_text, range, and showgrid.

Follow-up: How would you apply one change to selected axes in a multi-axis figure? Use the method's selector-related arguments to restrict which y-axes receive the update.

QHow are y-axis properties supplied?

Pass axis properties as keyword arguments, for example fig.update_yaxes(title_text="Value", showgrid=False). The method is intended for updating multiple nested axis properties without directly editing the layout dictionary.

Follow-up: How can you update axes in a faceted figure? Apply the method to the figure and use its axis-selection options when a subset rather than every y-axis should change.

QWhat should you watch for when setting range?

The range property accepts a two-value list defining the axis bounds. For a logarithmic axis, the bounds must be expressed after taking the logarithm of the desired data limits.

Follow-up: What alternative can preserve a fixed visual relationship between axes? Configure the relevant axis scale or anchoring properties, including scaleanchor where appropriate.

  • fig.update_xaxes
  • fig.for_each_yaxis
  • fig.update_layout
  • layout.yaxis

Source: Axes in Python. Checked 2026-10-15.