The PieChart Command

Syntax

This command allows you to create a pie chart from a list of data. We have two available syntaxes for it: PieChart(List of frequencies) that creates a pie chart using the given list of frequencies, in which the whole pie represents 100%, and the provided data are shown as slices. The center of the pie is by default at (0,0) and the default radius of the pie is 3. PieChart(List of frequencies, Center, Radius) that creates a pie chart with given center and radius, using the provided list of data. In this case you can define center and radius of the pie. The center can be an already existing point, or a new one, directly defined in the command.

Let's create a pie chart!

Have a look at the table in the app below, that shows the results of a survey addressed to 3 age groups (children up to 10 years old, kids and teens from 11 to 18 years old, and adults), asking them their favorite pasta sauce or seasoning, among 3 choices. Follow the instructions, and create three pie charts illustrating the results of the survey.

Instructions

1. Create a list containing the survey results for the Children category, in the same order as data are shown in the table. In the input bar, type: children={40,45,15} then press Enter to confirm the input. Note: don't enter the percentage symbols in the list.
2. Create the chart: in the input bar, type: PieChart(children) then press Enter to confirm the input. The chart is displayed in the Graphics View: you can drag it, and use the mouse wheel (computer) or the predefined gestures (mobile) to zoom in and out the graph. The displayed colors are the default ones.
3. Customize the graph, using the same colors of the table: select the menu icon displayed at the end of the row containing the PieChart command in Algebra View, (or right click on the graph, if you are using a computer), then select Settings to open the dialog window of the pie settings.
  • In the Basic tab, type the caption Children
  • In the Color tab, select Slice 1 from the drop-down list at the bottom (default selection All slices). Slice 1 refers to the first value in the children list, so their preference for butter or oil. Select a light yellow color for this slice, to match the corresponding line in the table.
Repeat as above, and change the colors of the other two slices, then close the Settings dialog window of the pie chart.
You might also want to drag the graph caption to a new position, and if you know LaTeX you can customize the font, dimension and other visual characteristics of the caption, including the string containing the LaTeX tags between two $ symbols, e.g. $\bold{Children}$. Create the pie charts for the other two age groups, following the steps described above.

Try it yourself...

A customizable syntax

The syntax PieChart(List of frequencies, Center, Radius) allows you to choose the dimension and position of the pie chart. Show the axes in the app above, by selecting the related option in the context menu of the Settings, so you can see the current configuration of Graphics View, then decide a center and a radius for the pie chart, and use these values in the command syntax, e.g. PieChart(children,(1,2), 5). In this case you also defined the center point directly in the command syntax. The center point will not be displayed either in Algebra and Graphics View.

... what if the sum of the values in the list is not 100?

Now delete the content of the app above, and enter the command PieChart({7,15,25}). As you can see, you can use a list of values directly in the command, avoiding to create it beforehand. Please remember to enclose in braces the values of your list. While in the first example about the survey results the sum of the values in the list was 100, thus representing the 100% of the sample, in this case the sum of the values used to create the pie chart is not 100. How can we then relate these values to the angle size of the displayed slices? Use the GeoGebra tools to measure the central angle that defines a slice, compare that size to the size of a turn, and formulate your conjecture about why the pie chart has this layout.