At My Fingertips

Simple Radar Chart

A radar chart can visualize three or more quantitative values. Each value is represented along a separate axis. The axes originate at a central point, and fan out in all directions like the spokes of a wheel. This kind of chart is known under many different names, such as Kiviat diagram, star chart, and spider chart.

Radar charts are often used to visually represent some kind of profile, for example to chart the various strenghts of a sports player.

A radar chart is similar to an area chart, but it uses a polar coordinate system.

Interface

Let's implement a function that turns a list of numbers into a radar chart.

def radar_chart(
  values: list[float], max_axis: float, color: Color, radius: float
) -> Graphic:

The function takes the following parameters:

  • values -- the list of numerical values to plot
  • max_axis -- the maximum value the chart will be able to represent; it corresponds to the value at the outside end of the axes.
  • color -- the color with which to fill the area.
  • radius -- the radius (the length of a spoke) of the visualization.

In the end, you should be able to call it like this:

radar_chart([1.0, 2.0, 1.5, 2.0, 1.5], 2.0, blue, 200)

This call should produce the following chart:

simple-radar-chart-2.png

The first value (1.0) is plotted on the spoke that points towards the right, the second value (2.0) on the spoke that faces towards the top-right, and so on. That is, the values are represented on spokes in counter-clockwise order.

Decomposition

The radar chart can be decomposed into the background polygon, the colored polygon representing the data points, and the spokes. For a list with N data points, the background polygon consists of N equilateral triangles, the colored polygon consists of N triangles, and the spokes consist of N very thin rectangles.

Implementation

To simplify your task, let's assume that there will be at least four values; this means that the angles between spokes will be at most 90 degrees.

Loading...
Loading...

What You Learned

You learned about the composition of a radar chart.


This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.

Simple Radar Chart

Logo of PyTamaro

PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI

Privacy Policy • Platform Version c3a8286 (Mon, 14 Oct 2024 13:30:28 GMT)