# `plot`::`Piechart3d`

3D pie charts

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```plot::Piechart3d(`[d1, d2,...]`, <`a = amin .. amax`>, `options`)
plot::Piechart3d(`A`, <`a = amin .. amax`>, `options`)
```

## Description

```plot::Piechart3d([d1, d2, d3, …])``` creates a corresponding 3D pie chart.

With the input data `d1`, `d2` etc., the i-th piece of the pie has the opening angle $\frac{2\pi {d}_{i}}{{d}_{1}{d}_{2}\dots }$.

The attribute `Titles` lets you attach titles to the pieces of the pie. In contrast to the overall title of the pie chart (`Title`, `TitleFont`), the titles of the pieces react to `TextFont`.

The attribute `Moves` lets you move the pieces away from the pie center for highlighting.

The attribute `Heights` lets you vary heights of the pieces.

The attributes `Center` and `Radius` let you position and scale a pie chart relative to other graphical objects in the same scene.

## Attributes

AttributePurposeDefault Value
`AffectViewingBox`influence of objects on the `ViewingBox` of a scene`TRUE`
`Billboarding`text orientation in space or towards observer`TRUE`
`Center`center of objects, rotation center[`0`, `0`, `0`]
`CenterX`center of objects, rotation center, x-component`0`
`CenterY`center of objects, rotation center, y-component`0`
`CenterZ`center of objects, rotation center, z-component`0`
`Color`the main color
`Colors`list of colors to use[`RGB::Blue`, `RGB::Red`, `RGB::Green`, `RGB::MuPADGold`, `RGB::Orange`, `RGB::Cyan`, `RGB::Magenta`, `RGB::LimeGreen`, `RGB::CadmiumYellowLight`, `RGB::AlizarinCrimson`]
`Data`the (statistical) data to plot[`1`]
`Filled`filled or transparent areas and surfaces`TRUE`
`Frames`the number of frames in an animation`50`
`Heights`heights of pieces in pie charts[`0.3`]
`Legend`makes a legend entry
`LegendText`short explanatory text for legend
`LegendEntry`add this object to the legend?`FALSE`
`LineColor`color of lines`RGB::Black.[0.25]`
`LineWidth`width of lines`0.35`
`LineStyle`solid, dashed or dotted lines?`Solid`
`LinesVisible`visibility of lines`TRUE`
`Moves`displacements of pieces in pie charts[`0`]
`Name`the name of a plot object (for browser and legend)
`ParameterEnd`end value of the animation parameter
`ParameterName`name of the animation parameter
`ParameterBegin`initial value of the animation parameter
`ParameterRange`range of the animation parameter
`Radius`radius of circles, spheres etc.`1`
`TextFont`font of text objects[`" sans-serif "`, `11`]
`TimeEnd`end time of the animation`10.0`
`TimeBegin`start time of the animation`0.0`
`TimeRange`the real time span of an animation`0.0` .. `10.0`
`Title`object title
`Titles`list of titles for object parts[`" "`]
`TitleFont`font of object titles[`" sans-serif "`, `11`]
`TitlePosition`position of object titles
`TitleAlignment`horizontal alignment of titles w.r.t. their coordinates`Center`
`TitlePositionX`position of object titles, x component
`TitlePositionY`position of object titles, y component
`TitlePositionZ`position of object titles, z component
`Visible`visibility`TRUE`
`VisibleAfter`object visible after this time value
`VisibleBefore`object visible until this time value
`VisibleFromTo`object visible during this time range
`VisibleAfterEnd`object visible after its animation time ended?`TRUE`
`VisibleBeforeBegin`object visible before its animation time starts?`TRUE`

## Examples

### Example 1

Create a 3D pie chart with pieces of the size ratios `1:2:1:3:2.5`.

```p := plot::Piechart3d([1, 2, 1, 3, 2.5]): plot(p)```

Set titles for the pieces:

```p::Titles := ["10.5%", "21.1%", "10.5%", "31.6%", "26.3%"]: plot(p)```

Pieces can be moved away from the pie center with the attribute `Moves`. One or more moves can be given as a `list` of values ```[f1, f2,...]```. The “move factors” `f1`, `f2`, and so on, are positive real values that represent fractions of the pie radius. The i-th piece is moved away from the center by `fi`. To move only some pieces, you can specify `Moves` = ```[n1 = f1, n2 = f2, …]```, such that only the pieces with indices `n1`, `n2`, and so on, are moved:

```p::Moves := [1 = 0.3, 3 = 0.5]: plot(p)```

The heights of the pieces in a 3D pie chart can vary:

```p::Heights := [0.1, 0.2, 0.1, 0.3, 0.25]: plot(p)```

`delete p:`

### Example 2

A pie chart can be animated. Plot a pie chart with an animated radius. The pieces move in and out, changing their size:

```m1 := piecewise([abs(a - PI/4) <= PI/4, sin(2*a)^2/3], [abs(a - PI/4) > PI/4, 0]): m2 := piecewise([abs(a - 3*PI/4) <= PI/4, sin(2*a)^2/3], [abs(a - 3*PI/4) > PI/4, 0]): m3 := piecewise([abs(a - 5*PI/4) <= PI/4, sin(2*a)^2/3], [abs(a - 5*PI/4) > PI/4, 0]): m4 := piecewise([abs(a - 7*PI/4) <= PI/4, sin(2*a)^2/3], [abs(a - 7*PI/4) > PI/4, 0]): p := plot::Piechart3d([5 + sin(a)/4, 2, 1 + sin(a)/2, 4], Title = "crazy pie chart", TitlePosition = [0, 15, 5], TitleFont = [Italic, 18], Center = [0, 0, 0], Radius = 10 + sin(2*a), Heights = [1.5 + sin(a), 1.5 + cos(2*a), 1.5 + sin(a), 1.5 + cos(4*a)], Titles = [1 = "piece 1", 2 = "piece 2", 3 = "piece 3", 4 = "piece 4"], Moves = [m1, m2, m3, m4], a = 0..2*PI): plot(p):```

`delete m1, m2, m3, m4, p:`

## Parameters

 `d1, d2, …` The sizes of the pieces: non-negative real values or arithmetical expressions of the animation parameter `a`. `d1, d2,...` is equivalent to the attribute `Data`. `A` A `matrix` or `array` containing the data `d1`, `d2`, and so on. `a` Animation parameter, specified as `a```` = amin..amax```, where `amin` is the initial parameter value, and `amax` is the final parameter value.

#### Mathematical Modeling with Symbolic Math Toolbox

Get examples and videos