Search code examples
pythonplotlyplotly-python

create custom marked degree for plotly windrose python


Is there a way to add additional degrees in windrose(default degrees marked as every 45° )? what I want to do is, mark degrees at every 22.5° instead of every 45°(0°,22.5°,45°,67.5° and so on).

I read the plotly windrose documentation, but couldn't able to find a suitable way to fix this.

enter image description here

code:

fig = px.bar_polar(df, r="Frequency", theta="wind_dir_Range",
                   color="Wind_Speed",
                   color_discrete_map={"0-10 km/h": "purple", "10-20 km/h": "cyan","20-30 km/h":"limegreen","30-40 km/h": "red"} 
  
                  )


fig.show()

Solution

    • have used alternate source of data... doesn't generate a good chart
    • however it does show that you can adjust tick size using dtick
    import plotly.express as px
    df = px.data.wind()
    df = df.assign(Direction=np.random.uniform(0,360,len(df)))
    
    fig = px.bar_polar(df, r="frequency", theta="Direction",
                       color="strength", template="plotly_dark",
                       color_discrete_sequence= px.colors.sequential.Plasma_r)
    fig.update_layout(polar={"angularaxis":{"dtick":45/2}})