我正在构建一个雷达图图表,并且我有一些变量将返回数组作为雷达图中的值。但是,它不显示我的值。你能给些建议么?谢谢!
变量输出:
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()
问题是[aa, bb, cc, dd, ee]
是一个数组列表而不是值列表。如果您按照下面的示例从数组中提取值,则代码应该可以工作。
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()