Radar Chart Using Python Plotly

A note on Web Charts🕸️ (aka: Radar Chart, Spider Chart):

Pros✅

  • Displays outliers evidently (Loki’s Deception)
  • Depict clear comparison across the same radial feature (comparison of strength across Iron-man, Thor & Loki )

Cons❌

  • It is hard to compare lengths of different spokes, because radial distances are hard to judge visually (comparing whether Loki’s speed is higher or magic)
  • The graph would appear cluttered if too many features are plotted

Where are they primarily used:

  • Comparison of skill levels across players, employees and super heroes XD

Code:

import pandas as pd
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import plotly.express as px
import plotly.io as pio
pio.templates.default = "plotly_white"


df = pd.DataFrame({'Character':["Iron Man","Iron Man","Iron Man","Iron Man","Iron Man","Iron Man","Thor","Thor","Thor","Thor","Thor","Thor","Loki","Loki","Loki","Loki","Loki","Loki"], 
                   'Skill':["Deception","Strength","Magic","Intelligence","Leadership","Speed","Deception","Strength","Magic","Intelligence","Leadership","Speed","Deception","Strength","Magic","Intelligence","Leadership","Speed"],
                   'Score':[60,70,0,90,90,70,30,95,80,50,80,70,100,30,80,95,35,75]})
 
df.head()
Table Output
fig = px.line_polar(df, r='Score', theta='Skill', line_close=True,color='Character')
fig.update_traces(fill='toself')
fig.update_layout(
    title={
        'text': "Dummy skill scores across Marvel Characters",
        'x':0.5,
        'xanchor': 'center',
        'yanchor': 'top'})
fig.update_layout(legend=dict(
    orientation="h",
    yanchor="bottom",
    y=-.15,
    xanchor="right",
    x=0.6
))

fig.show()
Chart Output

Blog at WordPress.com.

Up ↑