1

I am currently using Plotly's scatterpolar module to create a radar chart. I am trying to visualize the statistical categories for all 5 basketball statistics (points, assists, rebounds, steals, and blocks). The problem is that the range for every single category is set to the highest value which is points. I'd like to make the range for each category separate (for example: the range for points is 0 to 50, the range for assists to be 0 to 15, the range of steals to be 0 to 5,etc.).

This is what is looks like right now.

As you can see the entire chart is skewed towards the point category.

categories = ['Points', 'Assists', 'Rebounds', 'Steals', 'Blocks']
all_averages = [avg_points, avg_assists, avg_rebounds, avg_steals, avg_blocks]

trace = go.Scatterpolar(r = all_averages, theta = categories, fill = 'toself', name = f'{first} {last}')
data = [trace]
figure = go.Figure(data = data, layout = layout)
figure.show()

This is the code I have right now.

dimay
  • 2,768
  • 1
  • 13
  • 22
Justin Han
  • 13
  • 3
  • I checked to see if it is possible to determine the range of each indicator axis, but unfortunately there seems to be no such function. So, you will need to modify the data to the same range. If you want to set your own range, for example, you can add `range=[1,5]` to the radialaxis. – r-beginners Aug 03 '21 at 08:02

1 Answers1

4

One option is to scale each category then set the range 0-1.

import plotly.graph_objects as go

first = 'John'
last = 'Doe'

range_pts = 50
range_ast = 15
range_rbs = 20
range_stl = 5
range_blk = 5

ranges = [range_pts, range_ast, range_rbs, range_stl, range_blk]

categories = [f'Points ({range_pts})', f'Assists ({range_ast})', f'Rebounds ({range_rbs})', f'Steals ({range_stl})', f'Blocks ({range_blk})']
all_averages = [26, 7, 11, 2, 1]

for idx, value in enumerate(ranges):
    all_averages[idx] = all_averages[idx]/ranges[idx]


trace = go.Scatterpolar(r = all_averages, theta = categories, fill = 'toself', name = f'{first} {last}')
data = [trace]
figure = go.Figure(data = data, layout = None)
figure.update_polars(radialaxis=dict(visible=False,range=[0, 1]))
figure.show()

enter image description here

chitown88
  • 27,527
  • 4
  • 30
  • 59