与雷达图相比,Windrose的可定制性

时间:2018-07-31 18:10:22

标签: charts web-crawler plotly radar-chart rose-diagram

我正在寻找一种方法来显示一年中个人的属性,而不是第二年中显示的个人属性。大约有十二种度量,但是出于本示例的目的,我将其限制为6。我正在查看的两个viz选项是雷达/蜘蛛图和windrose图,但是,我遇到了windrose viz的布局选项存在问题。对于蜘蛛,我可以做这样的事情:

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")

这没问题,让我自定义径向范围和图形外部的属性名称。它还使我可以根据需要通过选中/取消选中每条迹线来与viz进行交互,但是当我尝试将相同的布局/方法引入windrose图表时,我无法进行许多相同的自定义。

我的windrose代码如下:

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')

此输出在图例中有3个不可检查的条目(Year1,Year2和一个随机的额外条目),径向范围自动设置(无论我的[0,1]输入如何),仅6 t -值('a','e','c')作为标签显示在图形的外部。非常感谢您对使这些更改适用于windrose的任何帮助或见解,谢谢!

0 个答案:

没有答案