Label and style an axis
Improve readability of a chart by setting a descriptive y-axis title and controlling gridlines.
Plotly · Module
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.
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.
fig.update_yaxes(**kwargs)| Name | Type | Description |
|---|---|---|
**kwargs | keyword arguments | Axis layout properties supplied as keyword arguments, including title_text, range, showgrid, visible, position, and other layout.yaxis attributes. |
A Plotly graph-object Figure with the requested y-axis properties updated.
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.
Improve readability of a chart by setting a descriptive y-axis title and controlling gridlines.
Focus a chart on a meaningful interval by explicitly setting its y-axis bounds.
Configure faceted or multi-axis figures by applying consistent y-axis settings across selected axes.
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.
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.
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_xaxesfig.for_each_yaxisfig.update_layoutlayout.yaxis