Radar Charts in Python: How to Build Spider or Polar Plots ?

Introduction

A radar plot (also called a spider chart or polar chart) is great for visualizing multivariate data — e.g., comparing several metrics or categories across multiple entities.

Here’s how to create one step by step using Matplotlib (and optionally Plotly for interactivity).

Basic Radar Plot with Matplotlib

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import matplotlib.pyplot as plt
import numpy as np

# Example data
categories = ['Accuracy', 'Precision', 'Recall', 'F1-Score', 'Speed']
values = [0.9, 0.8, 0.85, 0.88, 0.7]

# Close the circle by repeating the first value
values += values[:1]
N = len(categories)

# Compute angles for each category
angles = np.linspace(0, 2 * np.pi, N, endpoint=False).tolist()
angles += angles[:1]

# Create figure
fig, ax = plt.subplots(figsize=(6, 6), subplot_kw=dict(polar=True))

# Draw one axis per category + add labels
plt.xticks(angles[:-1], categories, color='black', size=12)

# Draw y-labels (radial)
ax.set_rlabel_position(30)
plt.yticks([0.2, 0.4, 0.6, 0.8], ["0.2", "0.4", "0.6", "0.8"], color="gray", size=10)
plt.ylim(0, 1)

# Plot data
ax.plot(angles, values, linewidth=2, linestyle='solid')
ax.fill(angles, values, 'skyblue', alpha=0.4)

plt.title("Model Performance", size=14, y=1.1)
plt.show()

Radar Charts in Python: How to Build Spider or Polar Plots ?
Radar Charts in Python: How to Build Spider or Polar Plots ?

Explanation

  • Converts categories into angular coordinates (in radians).
  • Closes the plot by repeating the first element.
  • Uses polar=True to draw in circular space.
  • Optionally fills the area for better visualization.

Compare Multiple Models

You can plot multiple datasets on the same radar chart:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
model_a = [0.9, 0.8, 0.85, 0.88, 0.7]
model_b = [0.75, 0.82, 0.8, 0.77, 0.9]

# Close the circle
model_a += model_a[:1]
model_b += model_b[:1]

fig, ax = plt.subplots(figsize=(6, 6), subplot_kw=dict(polar=True))
ax.plot(angles, model_a, 'b-', linewidth=2, label='Model A')
ax.fill(angles, model_a, 'b', alpha=0.2)
ax.plot(angles, model_b, 'r-', linewidth=2, label='Model B')
ax.fill(angles, model_b, 'r', alpha=0.2)

plt.xticks(angles[:-1], categories)
plt.title("Model Comparison", size=14, y=1.1)
plt.legend(loc='upper right', bbox_to_anchor=(1.3, 1.1))
plt.show()

Radar Charts in Python: How to Build Spider or Polar Plots ?
Radar Charts in Python: How to Build Spider or Polar Plots ?

Interactive Radar Plot with Plotly

If you want tooltips and interactive rotation/zoom:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import plotly.graph_objects as go

categories = ['Accuracy', 'Precision', 'Recall', 'F1-Score', 'Speed']
model_a = [0.9, 0.8, 0.85, 0.88, 0.7]
model_b = [0.75, 0.82, 0.8, 0.77, 0.9]

fig = go.Figure()

fig.add_trace(go.Scatterpolar(
    r=model_a,
    theta=categories,
    fill='toself',
    name='Model A'
))

fig.add_trace(go.Scatterpolar(
    r=model_b,
    theta=categories,
    fill='toself',
    name='Model B'
))

fig.update_layout(
    polar=dict(radialaxis=dict(visible=True, range=[0, 1])),
    showlegend=True,
    title="Interactive Radar Plot"
)

fig.show()

Radar Charts in Python: How to Build Spider or Polar Plots ?
Radar Charts in Python: How to Build Spider or Polar Plots ?

Basic Radar Plot with Pygal

What is Pygal?

Pygal is a Python library that generates interactive SVG charts — scalable vector graphics that are resolution-independent (great for web or print) and lightweight.

You can export Pygal charts as:

  • SVG files (interactive, zoomable, hover tooltips)
  • PNG, PDF, or browser-embedded HTML

Advantages of Pygal

Feature Advantage
Beautiful & Simple Syntax Very clean, high-level API — minimal setup.
Interactive SVG Output Charts are lightweight, scalable, and interactive (hover tooltips, clickable legends).
Embeddable Ideal for dashboards or web pages — easy to export to HTML.
Lightweight Doesn’t depend on large JavaScript bundles (unlike Plotly).
High-Resolution Friendly SVGs scale perfectly for presentations or print reports.
Offline & Static No need for a running server or JavaScript runtime — works offline.

Install Pygal

In your terminal or notebook, run:

1
pip install pygal

If you’re using Jupyter Notebook, you can install it directly from a cell:

1
!pip install pygal

After installation, test the import:

1
2
import pygal
print(pygal.__version__)

If that works, you’re ready to use it.

Example: Radar Chart with Pygal

Here’s a minimal example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
import pygal
from pygal.style import LightStyle

# Example data
categories = ['Accuracy', 'Precision', 'Recall', 'F1-Score', 'Speed']

radar_chart = pygal.Radar(fill=True, style=LightStyle)
radar_chart.title = 'Model Comparison'

radar_chart.x_labels = categories

radar_chart.add('Model A', [0.9, 0.8, 0.85, 0.88, 0.7])
radar_chart.add('Model B', [0.75, 0.82, 0.8, 0.77, 0.9])

# Show in browser or export
radar_chart.render_in_browser()
# or save as SVG
radar_chart.render_to_file('model_comparison.svg')

Tip: render_in_browser() opens the chart in your default web browser.
The SVG it produces is fully interactive — you can hover to see values.

Comparison with Other Libraries

Library Interactivity Output Type Strengths When to Use
Matplotlib Static PNG/PDF Highly customizable, scientific control Publication-quality static plots
Plotly High HTML/JS Full dashboard interactivity Data exploration or Dash apps
Pygal Medium SVG Lightweight, pretty, embeddable charts Static or lightweight web visualization

When do use Pygal

  • You want interactive but lightweight visuals (no large JS libraries).
  • You plan to embed charts in a blog, report, or static web page.
  • You like clean, declarative syntax without low-level tweaking.
  • You want vector-quality output (e.g., for PDFs, slides, print).

References

Links Site
https://matplotlib.org/stable/gallery/specialty_plots/radar_chart.html Matplotlib — Official Radar Chart Example
https://plotly.com/python/radar-chart/ Plotly — Official Radar (Spider) Chart Documentation
http://www.pygal.org/en/stable/documentation/types/radar.html Pygal — Official Radar Chart Documentation
Image

of