Skip to Main Content Skip to Search
Product Documentation

plot::Piechart2d2D pie charts

plot::Piechart3d3D pie charts

plot::Piechart2d([d_1, d_2, d_3, Symbol::dots]) creates a 2D pie chart with pieces of size ratios d_1Symbol::blank`:`Symbol::blankd_2Symbol::blank`:`Symbol::blankd_3Symbol::blank`:`Symbol::blankSymbol::dots.

plot::Piechart3d([d_1, d_2, d_3, Symbol::dots]) creates a corresponding 3D pie chart.

→ Examples

Calls:

plot::Piechart2d([d1, d2, ...], <a = amin .. amax>, Options)

plot::Piechart2d(A, <a = amin .. amax>, Options)

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

plot::Piechart3d(A, <a = amin .. amax>, Options)

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 etc.

See Also:

plot, plot::Bars2d, plot::Bars3d, plot::Boxplot, plot::copy, plot::Histogram2d, plot::Matrixplot

Details:

Example 1

We create a 2D pie chart with pieces of the size ratios 1Symbol::blank`:`Symbol::blank2Symbol::blank`:`Symbol::blank1Symbol::blank`:`Symbol::blank3Symbol::blank`:`Symbol::blank2.5.

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

MuPAD graphics

We set titles for the pieces:

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

MuPAD graphics

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 [f_1, f_2, Symbol::dots]. The “move factors” f1, f2 etc. are positive real values that represent fractions of the pie radius. The i-th piece is moved away from the center by fi. If not all pieces are to be, one may specify Moves = [n_1 = f_1, n_2 = f_2, Symbol::dots], such that only the pieces with indices n1, n2 etc. are moved:

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

MuPAD graphics

delete p:

Example 2

We create a 3D pie chart with pieces of the size ratios 1Symbol::blank`:`Symbol::blank2Symbol::blank`:`Symbol::blank1Symbol::blank`:`Symbol::blank3Symbol::blank`:`Symbol::blank2.5.

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

MuPAD graphics

We set titles for the pieces:

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

MuPAD graphics

Some pieces are moved away from the center:

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

MuPAD graphics

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)

MuPAD graphics

delete p:

Example 3

A pie chart can be animated. We 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):

MuPAD graphicsimage

delete m1, m2, m3, m4, p:

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS