Issue
I have created a gauge chart but I want to mention the meaning of labels, like 0 = low and 5 = high. that means I will need two labels (low on the left and high on the right).
Here is how my graph look like:
code:
import plotly.graph_objects as go
fig = go.Figure(go.Indicator(
domain = {'x': [0, 1], 'y': [0, 1]},
value = 4.3,
mode = "gauge+number+delta",
title = {'text': "General satisfaction"},
delta = {'reference': 2.5},
gauge = {'axis': {'range': [None, 5], 'tickwidth': 1,'tickcolor': "black"},
'bar': {'color': "MidnightBlue"},
'steps' : [
{'range': [0, 1], 'color': "DarkTurquoise"},
{'range': [1, 2], 'color': "MediumTurquoise"},
{'range': [2, 3], 'color': "Turquoise"},
{'range': [3, 4], 'color': "PaleTurquoise"},
{'range': [4, 5], 'color': "lightcyan"}],
'threshold' : {'line': {'color': "brown", 'width': 4}, 'thickness': 0.75, 'value': 4.8}}))
fig.show()
Is there any parameter that can help me in this case?
Solution
- graph objects indicator tickmode, tickvals and ticktext
- demonstrated below
fig.update_traces(
gauge={
"axis": {
"tickmode": "array",
"tickvals": list(range(6)),
"ticktext": ["0 - low" if i == 0 else "5 - high" if i==5 else i for i in range(6)],
}
}
)
Answered By - Rob Raymond
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.