plotly.py
plotly.py copied to clipboard
Indicator gauge autoscaling axes despite setting False
When using the gauge chart each time the chart generates the axes of the chart change despite setting autoscale to False.
If the chart is initialized and then repopulated using a new annotation at different iterations each new iteration will change the axes of the chart. The initialization functions correctly with the axes ranges set as directed but when the annotation is wiped and re-drawn the axes then shift.
The guage image itself appears the same but this changes the location of the annotation relative to the gauge.
Expected behavior: The chart axes should remain constant for the full life of the object unless explicitly changed. This would maintain the relationship between any annotations and the gauge image itself.
import plotly.graph_objs as go
import numpy as np
value = 0.06
fig = go.Figure(
go.Indicator(
mode='gauge',
value=100*value,
number={'suffix': "%"},
domain = {'x': [0, 1], 'y': [0, 1]},
gauge = {
'axis': {'range': [None, 100], 'tickwidth': 1},
'bar': {'color': "lightgray"},
'borderwidth': 2,
'steps': [
{'range': [0, 75], 'color': 'red'},
{'range': [75, 95], 'color': 'yellow'},
{'range': [95 ,100], 'color': 'green'}],
}
)
)
fig.update_layout(
margin=dict(t=20, b=10, l=10, r=10),
plot_bgcolor='rgba(0,0,0,0)',
xaxis={'showgrid': False, 'showticklabels': False, 'range':[-1,1], 'autoscale': False},
yaxis={'showgrid': False, 'showticklabels': False, 'range':[0,1], 'autoscale': False},
)
fig.update_yaxes(
scaleanchor="x",
scaleratio=1,
)
angle = np.pi*(1-value)
unit = np.array([np.cos(angle), np.sin(angle)])
ro = 0.8
ri = 0.
ax, ay = ri*unit
x, y = ro*unit
fig.add_annotation(
ax=ax,
ay=ay,
axref='x',
ayref='y',
x=x,
y=y,
xref='x',
yref='y',
showarrow=True,
arrowhead=3,
arrowsize=1,
arrowwidth=4
)
fig.show()
hi @acertainKnight Thanks for reporting. I tried running your locally but I'm getting this error:
Did you mean "autorange"? Bad property path: autoscale
Did you get that error as well?
Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson