How to rotate the dial in a gauge chart? Using python plotly

前端 未结 3 1073
天命终不由人
天命终不由人 2021-01-21 06:07

I am recently into using plotly package for a gauge chart in python.

After going through the tutorial and template here, I wonder if there is a way to

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-21 07:09

    In my case, the solution provided by @jvrsgsty needed a bit modification to work. That's how I finally fixed it:

    h = 0.24
    k = 0.5
    r = 0.15
    # Map my_raw_value to degrees. my_raw_value is between 0 and 300
    theta = (100 - my_raw_value) * 180 / 100
    # and then into radians
    theta = theta * math.pi / 180
    x = h + r*math.cos(theta)
    y = k + r*math.sin(theta)
    path = 'M 0.235 0.5 L ' + str(x) + ' ' + str(y) + ' L 0.245 0.5 Z'
    

提交回复
热议问题