Polar chart with Hours

Hi,
I am trying to build something like this clock chart:
clock_chart
I played with Scatterpolar but โ€˜thetaโ€™ comes only with degrees.
radar_chart
Is there any way to use hour values?

Hi @Denis,

Hereโ€™s an approach to get you started. Youโ€™ll still need to specify the data points in degrees, but you can setup the tick labels to display hours

import plotly.graph_objs as go

def angle2hr(angle):
    return (((angle - 15) % 360) + 15) / 15

def hr2angle(hr):
    return (hr * 15) % 360

def hr_str(hr):
    # Normalize hr to be between 1 and 12
    hr_str = str(((hr-1) % 12) + 1)
    suffix = ' AM' if (hr % 24) < 12 else ' PM'
    return hr_str + suffix

data = [
    go.Scatterpolar(
        r = [0.5,1,2,2.5,3,4],
        theta = [35,70,120,155,205,240],
        mode = 'markers',
        marker = dict(
            color = 'peru'
        )
    )
]

layout = go.Layout(
    showlegend = False,
)

layout.polar.angularaxis.direction = 'clockwise'
layout.polar.angularaxis.tickvals = [hr2angle(hr) for hr in range(24)]
layout.polar.angularaxis.ticktext = [hr_str(hr) for hr in range(24)]

fig = go.FigureWidget(data=data, layout=layout)
fig

newplot(7)

Hope that helps!
-Jon

1 Like

Hi @jmmease,
Thanks for your great workaround! It works!

1 Like