Hi, I’m looking for a way to display attributes for an individual in one year compared to the next year in plotly. There are about a dozen measures but for the purpose of this example I’ll limit it to 6. Two of the viz options I’m looking at are a radar/spider chart and a windrose chart, however, I’m running into an issue with the layout options for the windrose viz. For the spider, I can do something like this:
import plotly.graph_objs as go
from plotly.offline import plot, iplot, init_notebook_mode
t = go.Scatterpolar(
theta =[‘a’,‘b’,‘c’,‘d’,‘e’,‘f’],
r = [1,2,3,4,5,6],
mode = ‘lines’,
fill = ‘toself’,
fillcolor=‘red’,
line = dict(
color=‘black’),
hoverinfo=‘all’,
name= ‘Year 1’,
opacity=0.5
)
t1 = go.Scatterpolar(
theta =[‘a’,‘b’,‘c’,‘d’,‘e’,‘f’],
r = [2,4,6,8,10,12],
mode = ‘lines’,
fill = ‘toself’,
fillcolor=‘blue’,
line = dict(
color=‘black’),
hoverinfo=‘all’,
name= ‘Year 2’,
opacity=0.5
)
data=[t,t1]
layout = go.Layout(
title = ‘Y1 vs Y2 Spider’,
font=dict(
size=16
),
polar = dict(
radialaxis = dict(
visible = True,
range = [0,20], ticksuffix=’%’, tickangle=0, tickfont=dict(size=13)
),
angularaxis=dict(
nticks=6
)
))
fig = go.Figure(data=data, layout=layout)
iplot(fig, filename = “y1y2 spider.html”)
This works no problem and lets me customize the radial range and the names of the attributes on the outside of the graph. It also lets me interact with the viz in plotly by checking/unchecking each trace as desired, but when I try to bring the same layout/approach to the windrose chart, I’m unable to do many of the same customizations.
My windrose code looks like this:
trace1 = go.Area(
r = [1,2,3,4,5,6],
t = [‘a’,‘b’,‘c’,‘d’,‘e’,‘f’],
name= ‘Year 1’,
marker=dict(
color=‘red’
),
opacity=0.5
)
trace2 = go.Area(
r = [2,4,6,8,10,12],
t = [‘a’,‘b’,‘c’,‘d’,‘e’,‘f’],
name= ‘Year 2’,
marker=dict(
color=‘blue’
),
opacity=0.5
)
data = [trace1, trace2]
layout = go.Layout(
title = ‘Y1 vs Y2 Rose’,
font=dict(
size=16
),
polar = dict(
radialaxis = dict(
visible = True,
range = [0,20], ticksuffix=’%’, tickangle=0, tickfont=dict(size=13)
),
angularaxis=dict(
nticks=6
)
))
fig = go.Figure(data=data, layout=layout)
iplot(fig, filename=‘y1y2 rose.html’)
The output for this has 3 uncheckable entries in the legend (Year1, Year2, and a random extra one), the radial range automatically sets (regardless of my [0,1] input), and only some of the 6 t-values (‘a’,‘e’,‘c’) appear as labels on the outside of the graph. Any help or insight into making these changes work for the windrose would be greatly appreciated, thanks!