At My Fingertips
Rapid Playground
An area chart is similar to a bar chart. It visualizes a sequence of values. Each value determines the height of the area at a particular point. The values are represented at evenly spaced points along the x-axis.
In this activity we will develop the following function to create an area chart:
def area_chart(
values: list[float], y_min: float, y_max: float, width: float, height: float
) -> Graphic:
The parameters have the following meaning:
We can call the function as follows:
save_graphic("example-chart.png", area_chart([5, 10, 5, 20, 15], 0, 30, 200, 100))
This produces the following chart:
We can decompose an area chart into vertical slices. Horizontally, each slice goes from one data point to the next data point. Vertically, each slice consists of a right triangle sitting above a rectangle.
The height of the rectangle is the minimum of the two data points. The height of the triangle corresponds to the distance between the two data points.
You learned how to compose an area chart from rectangles and right triangles.
This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.
Simple Area Chart
PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI
Privacy Policy • Platform Version 0d7866a (Fri, 20 Dec 2024 07:46:38 GMT)