Configure grid lines, visibility, titles, or tick styling
Apply consistent styling across a figure or all subplots.
Plotly · Module
Updates layout properties on one or more x-axes in a Plotly graph-object figure. It can apply broadly or target a subplot with row and col selectors, and returns the modified figure.
Call this graph-object figure method with keyword arguments matching layout.xaxis properties. The update applies to the figure’s x-axes, and optional row and col selectors can limit the target axes in subplot figures; the method returns the modified figure reference for chaining.
fig.update_xaxes(patch=None, selector=None, overwrite=False, row=None, col=None, **kwargs)| Name | Type | Description |
|---|---|---|
**kwargs | xaxis property values | Axis layout properties such as title_text, range, showgrid, visible, type, and tick settings; these are passed as keyword arguments. |
row | int or None | Selects the subplot row whose x-axis should be updated. |
col | int or None | Selects the subplot column whose x-axis should be updated. |
A reference to the figure being modified.
import plotly.express as px
df = px.data.iris()
fig = px.scatter(
df,
x="sepal_width",
y="sepal_length",
color="species",
facet_col="species",
)
fig.update_xaxes(showgrid=False)
fig.show()Creates a faceted scatter plot and hides the grid on every x-axis.
Apply consistent styling across a figure or all subplots.
Change only one subplot’s x-axis.
Control displayed data bounds and scale behavior.
It updates one or more x-axis layout properties on a graph-object figure, such as title, range, visibility, grid, and tick settings. The keyword arguments correspond to layout.xaxis attributes.
Follow-up: How would you target one subplot? Pass row and col, for example fig.update_xaxes(title_text="x", row=1, col=2). The selectors restrict the update to that subplot axis.
By default, the method updates all x-axes in the figure. In subplot figures, row and col can select the axes associated with a particular subplot.
Follow-up: How can you update only axes satisfying a condition? Use the related for_each_xaxis method to apply logic across selected axis objects.
The method returns a reference to the figure being modified, so calls can be chained or the result can be assigned. It mutates the figure’s axis configuration rather than creating a separate chart.
Follow-up: What changes for a logarithmic axis range? Supply logarithmic exponents—for example, range=[0, 5] represents values from 1 through 100000.
fig.update_yaxesfig.for_each_xaxisfig.for_each_yaxislayout.xaxis