At My Fingertips
Rapid Playground
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.
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:
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:
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.
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.
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.
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
PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI
Privacy Policy ⢠Platform Version c08406b (Wed, 20 Nov 2024 12:30:00 GMT)