Reputation: 97
I have a scatterpolar plot, but the labels on the outside show the direction in terms of degrees rather than directions (N, NE, E, etc.). My data is in terms of degrees, so I will need to manually replace the labels shown on the plot. My current code is:
import pandas as pd
import plotly.graph_objs as go
# Get data
url = "https://raw.githubusercontent.com/mpudil/projects/master/slc.csv"
df = pd.read_csv(url)
fig = go.Figure(data=
go.Scatterpolar(
r = list(df['distance']),
theta = list(df['bearing']),
mode = 'markers',
name = 'log'
))
fig.update_layout(
polar = dict(
radialaxis = dict(type = "log", tickangle = 45),
angularaxis = dict(
thetaunit = "degrees",
dtick = 45,
rotation=90,
direction = "clockwise"
)
))
Which produces the plot below. Any suggestions to make the plot show the direction instead of degree? Thanks.
Note: The data can be found at https://github.com/mpudil/projects/blob/master/slc.csv
Upvotes: 2
Views: 2202
Reputation: 13437
Not sure if there is a better way but the following should work
fig.update_layout(
polar = dict(
radialaxis = dict(type = "log", tickangle = 45),
angularaxis = dict(
thetaunit = "degrees",
dtick = 45,
rotation=90,
direction = "clockwise",
tickmode="array",
tickvals=[0, 45, 90, 135, 180, 225, 270, 315],
ticktext=["N", "NE", "E", "SE", "S", "SW", "W", "NW"]
)
))
Upvotes: 3