ROAR.L
ROAR.L

Reputation: 333

Plotly Radar Chart - variables reference as the values

I'm building a plotly radar chart graph, and I have variables that return arrays as the values in the radar chart. However, it doesn't display my values. Can you please advise? Thanks!

Variables Output:

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

Upvotes: 0

Views: 298

Answers (1)

user11989081
user11989081

Reputation: 8663

If you extract the values from the arrays your code should work:

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

Upvotes: 2

Related Questions