Home > Mobile >  How to vertically position/align yaxis title at bottom in plotly express
How to vertically position/align yaxis title at bottom in plotly express

Time:07-12

I would like to create a plotly express line chart with a yaxis title that is positioned at the bottom of the axis instead of the center. This is what I have tried:

import pandas as pd
from plotly import express as px

df = pd.DataFrame({'x': range(0,10)})
fig = px.line(df).update_layout(yaxis_anchor='free', yaxis_position=0)

This is what I get:

enter image description here

This is the desired output:

enter image description here

CodePudding user response:

As far as I know, this location of the axes titles can't be changed. The argument yaxis_position=0 won't work because that changes the x coordinate of the yaxis in the plotting space.

However one possible workaround would be to set the yaxis title to an empty string, then place the text down as an enter image description here

  • Related