StatCrunch logo (home)

< StatCrunch Examples
Creating pie charts from raw data
This tutorial covers the steps for creating simple pie charts in StatCrunch. To begin, load the Two Categorical Variables data set, which will be used throughout this tutorial. This toy data set contains only two columns of data. The data in the var1 column, which will be used in this tutorial, contains 10 total values with the value b in the first four rows and the value a in the last six rows. This data set is in raw form in that it is not summarized with values in one column and counts/frequencies in another column. To construct pie charts with data in summary form see Creating pie charts from summary data.
Creating a pie chart of a column
StatCrunch can produce a pie chart for a column where the size of each slice is proportional to the proportion of times the associated value appears in a column. For example, to create a pie chart of the data in the var1 column, choose the Graph > Pie Chart > With Data menu option. Select the var1 column and click Compute!. The resulting pie chart is shown below with a legend tabling the values associated with each color in the chart as well as the count and percentage associated with each value. Note that the colors assigned to the values are determined by the color scheme selected for the pie chart. The pie chart shown below uses the default StatCrunch color scheme.
Controlling the legend display
The count and/or percent of total associated with each value can be tallied in the legend. For example, to alter the output above to only display the percent of total for each value, choose Options > Edit to reopen the pie chart dialog window. Change the Display options by deselecting Count and then click Compute!. This option can be deselected with a Ctrl+Click on Windows or Cmd+Click on a Mac. Alternatively, the mouse can be clicked and dragged to select the desired options. The resulting pie chart shown below only displays the percent of total in the legend.
Controlling the display of the slices
Under the Order by option, StatCrunch offers a number of different options for ordering the slices associated with each value. The default Value Ascending ordering places the a value before the b value using a standard alphabetical a to z ordering. The first slice is drawn at the default Start angle of 0 degrees in trigonometric terms. This corresponds to roughly 3 o'clock when thinking of the circle as a standard clock. The slices are then drawn in a counter clockwise direction based on the ordering selected. The display of the slices can be controlled by changing the Order by and Start angle options. For example, consider changing the above pie chart so that the b value appears before the a value and the slices start at 90 degrees (12 o'clock). In the window containing the resulting pie chart above, choose Options > Edit to reopen the pie chart dialog window. Change the Order by option to Value Descending, which will reverse the default alphabetical ordering, enter 90 for the Start angle option, and then press Compute! to obtain the pie chart with the desired characteristics shown below. Note the same display could be obtained with a Worksheet order since the b value appears before the a value in the var1 column. The Count Ascending and Count Descending options can be used to order the slices based on the frequencies associated with the values rather than the values themselves. In this example, changing to the Count Descending option will revert the values back to the original ordering because the a value has a higher frequency than the b value in the var1 column.
Combining all values with small relative frequencies into a single Other* category
In situations where a selected column has a few values which occur frequently and a larger number of values that do not occur often, the resulting pie chart can be quite messy with little room to properly label the values on each slice. In such cases, it is often times advantageous to combine the values with low relative frequencies into a single Other* category using the "Other*" if percent less than option in StatCrunch. To illustrate, in the window containing the resulting pie chart above, choose Options > Edit to reopen the pie chart dialog window. Change the "Other*" if percent less than option to 50 and click Compute!. In this case, the b value is simply relabeled as Other* since the b value only makes up 40% of the var1 column. While probably not a great idea for this data set, this change shows how StatCrunch can create a catch all category (Other*) by combining all categories with an associated percent of total below a specified threshold. The Other* category is also always displayed last in the ordering.

Always Learning