3

I created a bullet chart with a negative and positive dimension in plotly.go. However, when plotting my bar it always starts from -1. Is there a way to set the starting point at zero, so it can align in both dimensions from there? Reproducable example:

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"}}))

Actual Output: enter image description here

Output I want: enter image description here

LK1999
  • 113
  • 6
  • Do you have the expected graphical output because you don't understand the expected output image? – r-beginners Aug 29 '20 at 05:14
  • The expected output is like the above plot but without the bar ranging in the red area. So I want it to start in the middle and align to left or right accordingly. Do you know if there is a way to implement that? A workaround or something? – LK1999 Aug 29 '20 at 09:16

1 Answers1

2

I've done a lot of research and haven't found a solution. I propose a trick approach and a proposal to change the x-axis. This is a bit far from the answer you expect.

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()

enter image description here

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()

enter image description here

r-beginners
  • 31,170
  • 3
  • 14
  • 32