是否可以在情节中反转子弹图?
Is it possible to reverse bullet charts in plotly?
我在 plotly.go 中创建了一个带有负维度和正维度的子弹图。但是,在绘制我的条时,它总是从 -1 开始。有没有办法将起点设置为零,以便它可以从那里在两个维度上对齐?
可重现的例子:
act = 0.123
avg = 0.13
before = 0.15
fig = go.Figure(go.Indicator(
mode="number+gauge+delta", value=act,
domain={'x': [0.1, 1], 'y': [0, 1]},
title={'text': "<b>S-Score</b>"},
delta={'reference': before},
gauge={
'shape': "bullet",
'tick0':0,
'axis': {'range': [-1, 1]},
'threshold': {
'line': {'color': "white", 'width': 2},
'thickness': 0.75, 'value': avg},
'steps': [
{'range': [-1, 0], 'color': "#ff6666"},
{'range': [0, 1], 'color': "#89ac76"}
],
'bar': {'color': "grey"}}))
实际输出:
我想要的输出:
我做了很多研究,但没有找到解决方案。我提出了一种技巧方法和更改 x-axis 的建议。这和你期待的答案有点差距。
import plotly.graph_objects as go
act = 0.123
avg = 0.13
before = 0.15
fig = go.Figure(go.Indicator(
mode = "number+gauge+delta", value = act,
domain = {'x': [0.1, 1], 'y': [0, 1]},
title = {'text' :"<b>S-Score</b>"},
delta = {'reference': before},
gauge = {
'shape': "bullet",
'axis': {'range': [-1, 1]},
'threshold': {
'line': {'color': "white", 'width': 2},
'thickness': 0.75,
'value': avg},
'steps': [
{'range': [-1, 0], 'color': "#ff6666"},
{'range': [0, 1], 'color': "#89ac76"}],
'bar': {'color':'#ff6666'}
}))
fig.update_layout(height = 250)
fig.show()
import plotly.graph_objects as go
act = 0.123
avg = 0.13
before = 0.15
fig = go.Figure(go.Indicator(
mode = "number+gauge+delta", value = act,
domain = {'x': [0.1, 1], 'y': [0, 1]},
title = {'text' :"<b>S-Score</b>"},
delta = {'reference': before},
gauge = {
'shape': "bullet",
'axis': {'range': [0, 1]},
'threshold': {
'line': {'color': "white", 'width': 2},
'thickness': 0.75,
'value': avg},
'steps': [
{'range': [-1, 0], 'color': "#ff6666"},
{'range': [0, 1], 'color': "#89ac76"}],
'bar': {'color':'grey',
'line': {'color':'#444', 'width':2},
}}))
fig.update_layout(height = 250)
fig.show()
我在 plotly.go 中创建了一个带有负维度和正维度的子弹图。但是,在绘制我的条时,它总是从 -1 开始。有没有办法将起点设置为零,以便它可以从那里在两个维度上对齐? 可重现的例子:
act = 0.123
avg = 0.13
before = 0.15
fig = go.Figure(go.Indicator(
mode="number+gauge+delta", value=act,
domain={'x': [0.1, 1], 'y': [0, 1]},
title={'text': "<b>S-Score</b>"},
delta={'reference': before},
gauge={
'shape': "bullet",
'tick0':0,
'axis': {'range': [-1, 1]},
'threshold': {
'line': {'color': "white", 'width': 2},
'thickness': 0.75, 'value': avg},
'steps': [
{'range': [-1, 0], 'color': "#ff6666"},
{'range': [0, 1], 'color': "#89ac76"}
],
'bar': {'color': "grey"}}))
实际输出:
我想要的输出:
我做了很多研究,但没有找到解决方案。我提出了一种技巧方法和更改 x-axis 的建议。这和你期待的答案有点差距。
import plotly.graph_objects as go
act = 0.123
avg = 0.13
before = 0.15
fig = go.Figure(go.Indicator(
mode = "number+gauge+delta", value = act,
domain = {'x': [0.1, 1], 'y': [0, 1]},
title = {'text' :"<b>S-Score</b>"},
delta = {'reference': before},
gauge = {
'shape': "bullet",
'axis': {'range': [-1, 1]},
'threshold': {
'line': {'color': "white", 'width': 2},
'thickness': 0.75,
'value': avg},
'steps': [
{'range': [-1, 0], 'color': "#ff6666"},
{'range': [0, 1], 'color': "#89ac76"}],
'bar': {'color':'#ff6666'}
}))
fig.update_layout(height = 250)
fig.show()
import plotly.graph_objects as go
act = 0.123
avg = 0.13
before = 0.15
fig = go.Figure(go.Indicator(
mode = "number+gauge+delta", value = act,
domain = {'x': [0.1, 1], 'y': [0, 1]},
title = {'text' :"<b>S-Score</b>"},
delta = {'reference': before},
gauge = {
'shape': "bullet",
'axis': {'range': [0, 1]},
'threshold': {
'line': {'color': "white", 'width': 2},
'thickness': 0.75,
'value': avg},
'steps': [
{'range': [-1, 0], 'color': "#ff6666"},
{'range': [0, 1], 'color': "#89ac76"}],
'bar': {'color':'grey',
'line': {'color':'#444', 'width':2},
}}))
fig.update_layout(height = 250)
fig.show()