【问题标题】:Plotly Radar Chart - variables reference as the valuesPlotly 雷达图 - 变量引用作为值
【发布时间】:2020-08-13 08:42:45
【问题描述】:

我正在构建一个绘图雷达图,并且我有一些变量将数组作为雷达图中的值返回。但是,它没有显示我的价值观。你能给些建议么?谢谢!

变量输出:

output of aa > array([0.38570075]
output of bb > array([0.37840411]
output of cc > array([0.23178026]
output of dd > array([0.00411487]
output of ee > 0

import plotly.graph_objects as go

categories = ['A', 'B', 'C', 'D', 'E']

fig = go.Figure()

fig.add_trace(go.Scatterpolar(
      r=[aa,bb,cc,dd,ee],
      theta=categories,
      fill='toself',
      name='Egress & Access'
))
fig.update_layout(
  polar=dict(
    radialaxis=dict(
      visible=True,
      range=[0, 1]
    )),
      showlegend=True
)

fig.show()

【问题讨论】:

    标签: python plotly


    【解决方案1】:

    如果您从数组中提取值,您的代码应该可以工作:

    import plotly.graph_objects as go
    import numpy as np
    
    aa = np.array([0.38570075])
    bb = np.array([0.37840411])
    cc = np.array([0.23178026])
    dd = np.array([0.00411487])
    ee = 0
    
    categories = ['A', 'B', 'C', 'D', 'E']
    
    fig = go.Figure()
    
    fig.add_trace(go.Scatterpolar(
          r=[aa[0], bb[0], cc[0], dd[0], ee],
          theta=categories,
          fill='toself',
          name='Egress & Access'
    ))
    
    fig.update_layout(
      polar=dict(
        radialaxis=dict(
          visible=True,
          range=[0, 1]
        )),
          showlegend=True
    )
    
    fig.show()
    

    【讨论】:

    • 谢谢,在我将 np.array 添加到我的变量后它就可以工作了。谢谢!
    猜你喜欢
    • 2021-02-02
    • 2020-03-28
    • 1970-01-01
    • 1970-01-01
    • 2020-07-02
    • 2021-12-09
    • 1970-01-01
    • 2021-10-22
    • 1970-01-01
    相关资源
    最近更新 更多