import plotly.express as px
import pandas as pd
df = pd.DataFrame(dict(
r=[1,2,3],
theta=['a', 'b','c']))
fig = px.line_polar(df, r=[1,2,3], theta=['a','b','c'], line_close=True)
fig.update_polars(radialaxis_tickvals=[1,2,3,4,5], radialaxis_tickmode='array')
fig.show()
I have code like so that is able to generate a polar chart that looks like below
However what I want is to ensure that the maximum value of my tickvals is the maximum on the chart. So even though 3 is the highest value in this particular dataset, I want it to show tickvals 4 and 5 on the chart itself. This is so I can visually see that the 3 here is lower than the maximum otherwise when compared to other charts, at a glance it would look like 3 or 5 both meet the maximum.
>Solution :
You can use the radialaxis_range argument.
import plotly.express as px
import pandas as pd
df = pd.DataFrame(dict(r=[1, 2, 3], theta=["a", "b", "c"]))
fig = px.line_polar(df, r=[1, 2, 3], theta=["a", "b", "c"], line_close=True)
fig.update_polars(
radialaxis_tickvals=[1, 2, 3, 4, 5],
radialaxis_tickmode="array",
radialaxis_range=[0, 5], # Set the range of radial axis to always go up to 5
)
fig.show()
See here for the docs: https://plotly.com/python/reference/layout/polar/#layout-polar-radialaxis-range

