PIE Procedure
Displays data as a pie chart.
Usage
PIE, data[, labels]
Input Parameters
data — An array containing the data to plot as a pie chart.
labels — (optional) A string array of labels for the legend. The array must contain the same number of elements as data. If this parameter is not supplied, no legend is displayed.
Keywords
Colors — Sets an array of color indices specifying colors for the slices. If there are more slices than array elements, the colors are repeated. By default, the colors are chosen sequentially from the color table, excluding black and white. If Line_Fill is specified, the default color is !P.Color.
Line_Fill — If nonzero, a line fill algorithm is used to fill the slices. This keyword can also be set to an array of ones and zeroes to apply line filling to specific slices. (Default: no line filling)
Fill_Thick — A floating point scalar or array specifying the thickness of fill lines. If set to a scalar value, all slices receive the same line thickness. If set to an array, line thicknesses are mapped, in sequential slices, to the value of each array index. A thickness of 1 is normal, two is double-wide, and so on. (Default: !P.Thick)
 
note
This keyword has no effect unless Line_Fill is set.
Fill_Orientation — A floating-point scalar or array specifying the orientation of fill lines, in degrees counterclockwise from the horizontal. If set to a scalar, the orientation of fill lines in all slices is the same. If set to an array, the orientations are mapped, in sequential slices, to the value of each array index. (Default: each slice is set to a unique angle)
 
note
This keyword has no effect unless Line_Fill is set.
Fill_Linestyle — An integer or integer array specifying the style of fill lines. If set to a scalar, all slices are filled with the same linestyle. If set to an array, the linestyle of each slice is mapped, in sequential slices, to the value of each array index. (Default: !P.Linestyle)
 
note
This keyword has no effect unless Line_Fill is set.
Valid linestyle indices are shown in the Table 13-5: Linestyle Indices:
 
Linestyle Indices
Index
X Windows Style
Windows Style
0
Solid
Solid
1
Dotted
Short dashes
2
Dashed
Long dashes
3
Dash dot
Long-short dashes
4
Dash-dot-dot-dot
Long-short-short dashes
5
Long dashes
Long dashes
Fill_Spacing — A floating point scalar or array specifying the space, in centimeters, between fill lines. If a set to a scalar, the spacing between lines in all slices is the same. If set to an array, the spacing for each slice is mapped, in sequential slices, to the value of each array index. (Default: one percent of the width of the graphics window)
 
note
This keyword has no effect unless Line_Fill is set.
Fill_Background — An integer or integer array specifying the background color behind fill lines. If set to a scalar, the specified color applies to all of the slices. If set to an array, the colors for each slice are mapped, sequentially, to the value of each array index. Set this keyword to –1 to specify no background. (Default: no color behind fill lines)
 
note
This keyword has no effect unless Line_Fill is set.
Text_Color — An integer specifying the color index for the text used in titles and legends. (Defaults: !P.Color)
Outline_Color — An integer specifying the color index used for the outline of the pie slices and for the box around the legend. (Default: !P.Color)
NoLegend_Box — If nonzero, do not draw a box around the legend.
Legend_Position — Specifies the corner in which to place the legend. Choices are:
*0 — Northwest corner (Default)
*1 — Northeast corner
*2 — Southwest corner
*3 — Southeast corner
 
note
If you do not want a legend to appear, do not specify the labels input parameter.
Percent_Label — If nonzero, each slice is labeled with its percentage of the total pie. If the slice is too small so that the text won’t fit, then it is not labeled. You cannot specify both the Percent_Label and Value_Label keywords.
Value_Label — If nonzero, each slice is labeled with its value from the data array. If the slice is too small so that the text won’t fit, then it is not be labeled. You may not specify both the Percent_Label and Value_Label keywords.
Label_Colors — Colors used for the slice labels, if one of Percent_Label or Value_Label is set. May be a scalar or an array. If If set to a scalar, the specified color applies to all of the slices. If set to an array, the colors for each slice are mapped, sequentially, to the value of each array index. (Default: !P.Color)
Explode — An array of ones and zeroes specifying which (if any) slices should be “exploded” (drawn away from the center of the pie circle). This array must have the same number of elements as data. (Default: not exploded)
Offset_Explode — A scalar specifying the offset from the center of the circle for exploded slices. The value is a fraction of the circle radius. (Default: 0.1)
Shadow_Color — An integer specifying the color index for a shadow under the circle. (Default: no shadow)
Offset_Shadow — A scalar specifying the offset from the center of the pie circle for the shadow. The value is a fraction of the circle radius. (Default: 0.05)
Slice_Start_Ang — A floating point value specifying the angle, in degrees clockwise from the vertical, where to start drawing the first slice — the slice represented by data(0). (Default: 0 (vertical)).
Slice_Reverse_Direction — If nonzero, draws slices in counterclockwise order rather than in the default direction, clockwise.
Other PIE keywords are listed below. For a description of each keyword, see Chapter 21: Graphics and Plotting Keywords.
 
Discussion
PIE and PIE_CHART produce similar looking graphics. PIE includes a legend option and always ensures that label text and graphics fall within the plot window.
A legend for the colored pie slices is displayed in one corner, and labels (percent or data value) may be displayed on the slices.
If the legend occupies a significant portion of the plot area, there may not be enough room for the pie chart. The pie may be drawn very small, or it may overlap the legend. Use a smaller character size or a larger window.
Some combinations of shadowing and explosion may cause the pie to be slightly smaller than you may consider optimal. Sometimes, the shadow may overlap the corner of the legend box. Try moving the legend to the left side (set the keyword Legend_Position to 0 or 2).
Negative values in data produce unwanted plotting results (some slices are plotted backwards); therefore, the absolute value of data is plotted. All labels, however, will display the correct negative values.
You can not use !P.Multi, !P.Position, and !P.Region with PIE.
Examples
This example demonstrates how to create a pie chart. The results are shown in Figure 13-1: Example Pie Chart.
; Create data 
data = FLTARR(4)
data(0) = 32
data(1) = 22
data(2) = 11
data(3) = 35
; Create labels
strg = STRARR(4)
strg(0) = 'Renault'
strg(1) = 'Peugeot'
strg(2) = 'Citroen'
strg(3) = 'Others'
title = '!18French automobile market shares'
TEK_COLOR
; Create pie chart
PIE, data, strg, /Line_fill, Title=title, $
   Color=WoColorConvert(INDGEN(4)+5), $
   Fill_background=-1, $
   /Percent_label, Text_color=WoColorConvert(1)
 
Figure 13-1: Example Pie Chart
 
 
See Also