PieChart

PieChart[{y1,y2,,yn}]

makes a pie chart with sector angle proportional to y1, y2, .

PieChart[{,wi[yi,],,wj[yj,],}]

makes a pie chart with sector features defined by the symbolic wrappers wk.

PieChart[{data1,data2,}]

makes a pie chart from multiple datasets datai.

Details and Options

  • Pie charts are also known as donut charts when a hole is left in the middle.
  • PieChart shows the values in a dataset as proportional slices of a whole circle. Pie charts are typically used when the data is small.
  • Data elements for PieChart can be given in the following forms:
  • yia pure sector value
    Quantity[yi,unit]sector value with a unit
    wi[yi,]a sector with value yi and wrapper wi
    formi->mia sector form with metadata mi
  • Data not given in these forms is ignored in forming the pie chart.
  • Datasets for PieChart can be given in the following forms:
  • {e1,e2,}list of elements with or without wrappers
    <|k1y1,k2y2,|>association of keys and values
    TimeSeries[],EventSeries[],TemporalData[]time series, event series, and temporal data
    WeightedData[],EventData[]augmented datasets
    w[{e1,e2,},]wrapper applied to a whole dataset
    w[{data1,data1,},]wrapper applied to all datasets
  • The following wrappers can be used for chart elements:
  • Annotation[e,label]provide an annotation
    Button[e,action]define an action to execute when the element is clicked
    Callout[e,label]display the element with a callout
    EventHandler[e,]define a general event handler for the element
    Hyperlink[e,uri]make the element act as a hyperlink
    Labeled[e,]display the element with labeling
    Legended[e,]include features of the element in a chart legend
    Mouseover[e,over]make the element show a mouseover form
    PopupWindow[e,cont]attach a popup window to the element
    StatusArea[e,label]display in the status area when the element is moused over
    Style[e,opts]show the element using the specified styles
    Tooltip[e,label]attach an arbitrary tooltip to the element
  • In PieChart, Labeled and Placed allow the following positions:
  • "RadialOuter","RadialCenter","RadialInner"positions within sectors
    "RadialOutside","RadialInside","RadialEdge"positions outside sectors
    "RadialCallout", "VerticalCallout"positions with callout lines
    {{sθ,sr},{lx,ly}}scaled position {lx,ly} in the label at scaled polar position {sθ,sr} in the sector
  • In PieChart, Callout allows the following positions pos:
  • Automaticautomatic placement
    {x,y}position in the graphic
    Scaled[{sθ,sr}]scaled polar position {sθ,sr} in the sector
    {pos,{lx,ly}}scaled position {lx,ly} in the label at position pos
  • PieChart has the same options as Graphics with the following additions and changes:
  • ChartBaseStyle Automaticoverall style for sectors
    ChartElementFunction Automatichow to generate raw graphics for sectors
    ChartLabels Nonelabels for data elements and datasets
    ChartLayout Automaticoverall layout to use
    ChartLegends Nonelegends for data elements and datasets
    ChartStyle Automaticstyle for sector
    ColorFunction Automatichow to color sectors
    ColorFunctionScaling Truewhether to normalize arguments to ColorFunction
    LabelingFunction Automatichow to label sectors
    LabelingSize Automaticmaximum size of callouts and labels
    LegendAppearanceAutomaticoverall appearance of legends
    PerformanceGoal $PerformanceGoalaspects of performance to try to optimize
    PlotRangeAutomaticrange of values to include
    PlotTheme $PlotThemeoverall theme for the chart
    PolarAxesFalsewhether to draw polar axes
    PolarAxesOriginAutomaticwhere to draw polar axes
    PolarGridLinesNonepolar gridlines to draw
    PolarTicksAutomaticpolar axes ticks
    SectorOrigin Automaticinitial angle and radius of sectors
    SectorSpacing Automaticspacing between sectors
    TargetUnitsAutomaticunits to display in the chart
  • Possible settings for ChartLayout that show multiple datasets in a single display panel include:
  • "Grouped"separate the data for each dataset
    "Stacked"accumulate the data for each dataset
  • Possible settings for ChartLayout that show individual datasets in different panels include:
  • "Column"use separate charts in a column of panels
    "Row"use separate charts in a row of panels
    {"Column",k},{"Row",k}use k columns or rows
    {"Column",UpTo[k]},{"Row",UpTo[k]}use at most k columns or rows
  • The arguments supplied to ChartElementFunction are the sector region {{θmin,θmax},{rmin,rmax}}, the values yi, and the metadata {m1,m2,} from each level in a nested list of datasets.
  • A list of built-in settings for ChartElementFunction can be obtained from ChartElementData["PieChart"].
  • The argument supplied to ColorFunction is yi.
  • Style and other specifications from options and other constructs in PieChart are effectively applied in the order ChartStyle, ColorFunction, Style and other wrappers, and ChartElementFunction, with later specifications overriding earlier ones.

Examples

open allclose all

Basic Examples  (5)

Generate a pie chart for a list of values:

Generate a donut chart for a list of values:

Generate a pie chart for multiple datasets:

Show multiple sets as a row of pie charts:

Use categorical labels:

Categorical legends:

Set the style for sectors:

Scope  (37)

Data and Layouts  (13)

Items in a dataset are grouped together:

Datasets do not need to have the same number of items:

Nonreal data is taken to be missing and typically is ignored in the pie chart:

The data may include units:

Specify the units to use:

The time stamps in TimeSeries, EventSeries, and TemporalData are ignored:

The values in associations are taken as the values of the sectors:

Use the keys as labels:

Use the keys as callouts above the sectors:

Use the keys as legends:

Associations can be nested:

The weights in WeightedData are ignored:

The censoring and truncation information in EventData is ignored:

Use different layouts to display multiple datasets:

Control the direction of sectors:

Control the starting angle of sectors:

Control the starting radius of sectors:

Adjust the spacing between sectors and groups of sectors:

Wrappers  (5)

Use wrappers on individual data, datasets, or collections of datasets:

Wrappers can be nested:

Override the default tooltips:

Use any object in the tooltip:

Use PopupWindow to provide additional drilldown information:

Button can be used to trigger any action:

Styling and Appearance  (7)

Use an explicit list of styles for the sectors:

Use any gradient or indexed color schemes from ColorData:

Use color schemes designed for charting:

ChartBaseStyle can be used to set an initial style for all chart elements:

Style can be used to override styles:

Use built-in programmatically generated sectors:

For detailed settings use Palettes ChartElementSchemes:

Use a theme with a high-contrast color scheme and bezel sectors:

Use a monochrome theme:

Labeling and Legending  (12)

Use Labeled to add a label to a sector:

Use symbolic positions for label placement:

Provide categorical labels for the columns of data:

For rows of data:

For both:

Use Placed to control the positioning of labels, using the same positions as for Labeled:

Use Callout to add a label to a sector:

Change the appearance of the callout:

Automatically position callouts:

Provide value labels for sectors by using LabelingFunction:

Generate callouts from the data:

Add categorical legend entries for the columns of data:

For rows of data:

Use Legended to add additional legend entries:

Use Placed to affect the positioning of legends:

Options  (75)

ChartBaseStyle  (5)

Use ChartBaseStyle to style sectors:

ChartBaseStyle combines with ChartStyle:

ChartStyle may override settings for ChartBaseStyle:

ChartBaseStyle combines with Style:

Style may override settings for ChartBaseStyle:

ChartBaseStyle combines with ColorFunction:

ColorFunction may override settings for ChartBaseStyle:

ChartElementFunction  (6)

Possible string values for ChartElementFunction:

For detailed settings, use Palettes ChartElementSchemes:

Use ChartElementData to specify the full chart element rendering function:

Write a custom ChartElementFunction:

Use metadata passed on from the input, in this case charting the data:

Built-in element functions may have options; use Palettes ChartElementSchemes to set them:

ChartLabels  (8)

By default, labels are placed radially centered:

Labeled wrappers in data will place additional labels:

Use Placed to control label placement:

Positions outside the sector:

Callout positions:

Coordinate based placement relative to a sector:

Place all labels at the first outer corner and vary the coordinates within the label:

Use the third argument to Placed to control formatting:

Use a hyperlink label:

By default, labels are associated with columns of data:

Associate labels with rows or datasets:

Label both rows and columns:

Use Placed to affect placements:

Use Callout to connect the labels to the sectors:

Place multiple labels:

ChartLayout  (4)

ChartLayout is grouped by default in concentric rings:

Use stacked sectors:

The stacked layout can effectively display many datasets:

Place each set in a separate panel:

Use a row instead of a column:

Use multiple columns or rows:

Prefer full columns or rows:

ChartLegends  (8)

Generate a legend based on chart style:

Use Legended to add additional legend entries:

Use Legended to specify individual legend entries:

Legended adds additional legend entries:

Generate a legend for datasets:

Unused legend labels are dropped:

Legends can be applied to several dimensions:

Use Placed to control the placement of legends:

ChartStyle  (7)

Use ChartStyle to style sectors:

Give a list of styles:

Use gradient colors from ColorData:

Use indexed colors from ColorData:

Use indexed colors optimized for charting:

Styles are used cyclically:

Style each column of data:

Style each row of data:

Style both rows and columns of data:

With both row and column styles, the last style may override earlier ones:

Style overrides settings for ChartStyle:

ColorFunction overrides settings for ChartStyle:

ColorFunction  (3)

Color by sector angle:

Use ColorFunctionScaling->False to get unscaled height values:

ColorFunction overrides styles in ChartStyle:

Use ColorFunction to combine different style effects:

ColorFunctionScaling  (3)

By default, scaled height values are used:

Set ColorFunctionScaling to False to allow raw values to be passed to the color function:

Use ColorFunctionScaling->False to get unscaled height values:

ImageSize  (7)

Use named sizes, such as Tiny, Small, Medium and Large:

Specify the width of the plot:

Specify the height of the plot:

Allow the width and height to be up to a certain size:

Specify the width and height for a graphic, padding with space if necessary:

Use maximum sizes for the width and height:

Use ImageSizeFull to fill the available space in an object:

Specify the image size as a fraction of the available space:

LabelingFunction  (7)

Use automatic labeling by values through Tooltip and StatusArea:

Do no labeling:

Use Placed to control label placement:

Positions outside the sector:

Callout positions:

Coordinate-based placement relative to a sector:

Use Callout to place labels automatically:

Control the formatting of labels:

Use the given chart labels as arguments to the labeling function:

Place complete labels as tooltips:

LabelingSize  (4)

Textual labels are shown at their actual sizes:

Image labels are automatically resized:

Specify a maximum size for textual labels:

Specify a maximum size for image labels:

Show image labels at their natural sizes:

PerformanceGoal  (3)

Generate a pie chart with interactive highlighting:

Emphasize performance by disabling interactive behaviors:

Typically, less memory is required for noninteractive charts:

PlotTheme  (1)

Use a theme with a high-contrast color scheme and bezel sectors:

Change the chart element function:

SectorOrigin  (4)

By default, sectors start on the left and add clockwise:

Generate a donut chart for a list of values:

Reverse the direction of the sectors:

Rotate the chart by :

SectorSpacing  (5)

Use automatically determined spacing between sectors:

Use no spacing:

Use symbolic presets:

Use explicit spacing between sectors:

Use explicit spacing between sectors and groups of sectors:

Applications  (15)

Create a circular histogram:

Improve legibility of small segments by charting them with an auxiliary pie chart:

Improve legibility of small segments by charting them with an auxiliary bar chart:

Use a stacked bar chart to represent small segments:

Click on the sectors to hear the name of the country and its GDP per capita:

Proportion of each color in the United States flag:

Tally the most frequently used colors:

Chart it:

GDP comparison of G7 nations:

Percentage of total elements discovered by countries:

Count the number of times each letter occurs in a sentence:

Group sectors by product type:

Create a pie chart capable of interactive drilling down of a stock portfolio:

Mouse over a sector to get a pie chart of the companies that comprise that sector:

Click on a sector to get a pie chart of the companies that comprise that sector:

Display oil data for the G15 countries using pie charts to indicate import and export:

Create a chart of individual pie chart sectors:

Create a pie chart histogram of element discovery years from 1700 to 2000:

Define a chart element function that stores bin intervals and count data using Sow:

Create a histogram of the discovery years and store the bin interval and frequencies:

Create a histogram pie chart of element discovery years:

Visualize chemical composition using pie charts:

Analyze locations of strong earthquakes:

Define continents and oceans:

Count the number of earthquakes per region:

Select regions with earthquakes:

Properties & Relations  (4)

Use PieChart3D to get a 3D rendering of pie charts:

PieChart is a special case of SectorChart:

Use BarChart and BarChart3D to draw a list of data as bars:

Use ListPlot and ListLinePlot to produce line graphs:

Neat Examples  (3)

A hue saturation color wheel:

Chartwork:

Wolfram Research (2008), PieChart, Wolfram Language function, https://reference.wolfram.com/language/ref/PieChart.html (updated 2021).

Text

Wolfram Research (2008), PieChart, Wolfram Language function, https://reference.wolfram.com/language/ref/PieChart.html (updated 2021).

CMS

Wolfram Language. 2008. "PieChart." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/PieChart.html.

APA

Wolfram Language. (2008). PieChart. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PieChart.html

BibTeX

@misc{reference.wolfram_2022_piechart, author="Wolfram Research", title="{PieChart}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/PieChart.html}", note=[Accessed: 02-June-2023 ]}

BibLaTeX

@online{reference.wolfram_2022_piechart, organization={Wolfram Research}, title={PieChart}, year={2021}, url={https://reference.wolfram.com/language/ref/PieChart.html}, note=[Accessed: 02-June-2023 ]}