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.


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


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 2πdid1d2.

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.


AttributePurposeDefault Value
AffectViewingBoxinfluence of objects on the ViewingBox of a sceneTRUE
Billboardingtext orientation in space or towards observerTRUE
Centercenter of objects, rotation center[0, 0, 0]
CenterXcenter of objects, rotation center, x-component0
CenterYcenter of objects, rotation center, y-component0
CenterZcenter of objects, rotation center, z-component0
Colorthe main color 
Colorslist of colors to use[RGB::Blue, RGB::Red, RGB::Green, RGB::MuPADGold, RGB::Orange, RGB::Cyan, RGB::Magenta, RGB::LimeGreen, RGB::CadmiumYellowLight, RGB::AlizarinCrimson]
Datathe (statistical) data to plot[1]
Filledfilled or transparent areas and surfacesTRUE
Framesthe number of frames in an animation50
Heightsheights of pieces in pie charts[0.3]
Legendmakes a legend entry 
LegendTextshort explanatory text for legend 
LegendEntryadd this object to the legend?FALSE
LineColorcolor of linesRGB::Black.[0.25]
LineWidthwidth of lines0.35
LineStylesolid, dashed or dotted lines?Solid
LinesVisiblevisibility of linesTRUE
Movesdisplacements of pieces in pie charts[0]
Namethe name of a plot object (for browser and legend) 
ParameterEndend value of the animation parameter 
ParameterNamename of the animation parameter 
ParameterBegininitial value of the animation parameter 
ParameterRangerange of the animation parameter 
Radiusradius of circles, spheres etc.1
TextFontfont of text objects[" sans-serif ", 11]
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0
Titleobject title 
Titleslist of titles for object parts[" "]
TitleFontfont of object titles[" sans-serif ", 11]
TitlePositionposition of object titles 
TitleAlignmenthorizontal alignment of titles w.r.t. their coordinatesCenter
TitlePositionXposition of object titles, x component 
TitlePositionYposition of object titles, y component 
TitlePositionZposition of object titles, z component 
VisibleAfterobject visible after this time value 
VisibleBeforeobject visible until this time value 
VisibleFromToobject visible during this time range 
VisibleAfterEndobject visible after its animation time ended?TRUE
VisibleBeforeBeginobject visible before its animation time starts?TRUE


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]):

Set titles for the pieces:

p::Titles := ["10.5%", "21.1%", "10.5%", "31.6%", "26.3%"]:

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]:

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

p::Heights := [0.1, 0.2, 0.1, 0.3, 0.25]:

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):

delete m1, m2, m3, m4, p:


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 matrix or array containing the data d1, d2, and so on.


Animation parameter, specified as a = amin..amax, where amin is the initial parameter value, and amax is the final parameter value.