Scaling Value
1. Scaling values that have the same range
When all variables have the same range we can provide that range which will later be used for scaling. For example, when we know that school grades have a range of 1-10, we can specify that range of values when creating a radar plot
Here's an example of a dummy dataframe of Jake and Amy's school grades
import pandas as pd
df = pd.DataFrame({
'student': ['jake', 'amy'],
'Math': [6, 10],
'Science': [7, 9],
'Art': [10, 8],
})jake
6
7
10
amy
10
9
8
From the dummy dataframe we can create a radar plot in this way
import reverievis as rv
rv.radar(data=df,
category='student',
values=df.columns[1:].to_list(),
scaled=[0,10],
colors=['#FF6D60', '#6DA9E4'],
title='Jake vs Amy School Grades')
By giving the argument value range of Jake and Amy's school grades which is 0-10 on the parameter scaled. We have scaled the values so that the resulting radar plot is easy to read
2. Scaling values that have different ranges
When one variable with another variable has a different scale value, it is necessary to scale the value so that the resulting graph becomes readable.
For example, using the Penguins dataset from Seaborn, each physical characteristic of the penguins has a different value scale so it is necessary to do value scaling. here's how to do value scaling using Radarplot
rd.get_minmax is used to get the min and max values of each desired column. Where the min and max value is used to scale the column when visualization is carried out
Here's an average of the physical traits of each type of penguin in the dataframe
Adelie
38.791391
18.346358
3700.662252
189.953642
Chinstrap
48.833824
18.420588
3733.088235
195.823529
Gentoo
47.504878
14.982114
5076.016260
217.186992
species_df is used to create radar plots and data_minmax used to do value scaling behind the scenes and here are the code and graphic results

Last updated