Graphics - The MathWorks - #251

/ 667


catalogue search
P. 251
P. 252
P. 253
P. 254
P. 255
P. 256
P. 257
P. 258
P. 259
P. 260
P. 261
P. 262
P. 263
P. 264
P. 265
P. 266
P. 267
P. 268
P. 269
P. 270
P. 271
P. 272
P. 273
P. 274
P. 275
P. 276
P. 277
P. 278
P. 279
P. 280
P. 281
P. 282
P. 283
P. 284
P. 285
P. 286
P. 287
P. 288
P. 289
P. 290
P. 291
P. 292
P. 293
P. 294
P. 295
P. 296
P. 297
P. 298
P. 299
P. 300


See other catalogues for The MathWorks

Text version of the page
Pie Charts
Pie Charts
In this section...
"Creating a Pie Chart" on page 5-23 "Labeling the Pie Chart" on page 5-24 "Removing a Piece from a Pie Chart" on page 5-26
Creating a Pie Chart
Pie charts are a useful way to communicate the percentage that each element in a vector or matrix contributes to the sum of all elements. pie and pie3 create 2-D and 3-D pie charts. A 3-D pie chart does not show any more or different information than a 2-D pie chart does; it simply adds depth to the presentation by plotting the chart on top of a cylindrical base.
This example shows how to use the pie function to visualize the contribution that three products make to total sales. Given a matrix X where each column of X contains yearly sales figures for a specific product over a five-year period,
[19.3
22.1
51.6;
34.2
70.3
82.4;
61.4
82.9
90.8;
50.5
54.9
59.1;
29.4
36.3
47.0];
sum each row in X to calculate total sales for each product over the five-year period.
x = sum(X);
You can offset the slice of the pie that makes the greatest contribution using the explode input argument. This argument is a vector ofzero and nonzero values. Nonzero values offset the respective slice from the chart.
First, create a vector containing zeros. explode = zeros(size(x));
5-23

pageCatalog pdf di En 2012-06-22-01