文档

pie

Pie chart

句法

派(x)
派(x,爆炸)
派(x,标签)
派(x,爆炸,标签)
馅饼(斧头,___
p = pie(___

Description

例子

馅饼(Xdraws a pie chart using the data inX。饼图的每个切片代表X

  • 如果sum(x)≤1, 然后the values inXdirectly specify the areas of the pie slices.piedraws only a partial pie ifsum(X) < 1

  • 如果sum(X) > 1, 然后pie通过x/sum(x)to determine the area of each slice of the pie.

  • 如果X是数据类型categorical,,,,the slices correspond to categories. The area of each slice is the number of elements in the category divided by the number of elements inX

例子

馅饼(X,,,,爆炸offsets slices from the pie.爆炸is a vector or matrix of zeros and nonzeros that correspond toX。Thepie功能仅在非零元素中偏移切片爆炸

如果X是数据类型categorical, 然后爆炸can be a vector of zeros and nonzeros corresponding to categories, or a cell array of the names of categories to offset.

例子

馅饼(X,,,,标签specifies text labels for the slices. The number of labels must equal the number of slices.X必须是数字。

例子

馅饼(X,,,,爆炸,,,,标签specifies text labels for the slices. The number of labels must equal the number of slices.

例子

馅饼(斧头,,,,___图到指定的轴斧头instead of into the current axes (GCA)。选项斧头can precede any of the input argument combinations in the previous syntaxes.

例子

p= pie(pie(___返回补丁和文本图形对象的向量。输入可以是上一个语法中的任何输入参数组合。

例子

全部收缩

创建向量的饼图X

X= [1 3 0.5 2.5 2]; pie(X)

Offset the second and fourth pie slices by setting the corresponding爆炸元素为1。

爆炸= [0 1 0 1 0];派(x,爆炸)

创建向量的饼图X并标记切片。

x = 1:3;标签= {'Taxes',,,,'花费',,,,'利润'};派(x,标签)

创建标记的饼图,然后修改文本标签的颜色和字体大小。

x = 1:3;标签= {'Taxes',,,,'花费',,,,'利润'};p = pie(x,标签)
p = 1x6图形数组:补丁文本补丁文本补丁文本文本

获取标签“利润”的文本对象。更改其颜色和字体尺寸。从R2014B开始,您可以使用点符号来设置属性。如果您正在使用较早的版本,请使用function instead.

t = p(6);T.BackgroundColor ='cyan';t.edgecolor ='红色的';t.fontsize = 14;

创建向量的饼图X元素的总和小于1。

x = [0.19 0.22 0.41];派(x)

pie绘制部分派,因为元素的总和小于1。

创建两个数据和绘图的向量,并在其自己的饼图中标记每个向量。

X= [0.2 0.4 0.4]; labels = {'Taxes',,,,'花费',,,,'利润'};AX1 =子图(1,2,1);派(AX1,X,标签)标题(AX1,“ 2012年”);y = [0.24 0.46 0.3];AX2 =子图(1,2,2);派(AX2,Y,标签)标题(AX2,'2013');

绘制具有与类别相对应的偏移片的分类饼图。

X= categorical({'北',,,,'南',,,,'北',,,,'East',,,,'南',,,,'West'});爆炸= {'北',,,,'南'};派(x,爆炸)

现在,使用逻辑向量来抵消相同的切片。

爆炸= [0 1 1 0]; pie(X,explode)

在没有任何偏移片的情况下绘制一个分类饼图,并标记切片。什么时候X是数据类型categorical您必须指定输入参数爆炸。To specify labels without any offset slices, specify爆炸作为一个空的单元格数组,标签作为标签。

X= categorical({'北',,,,'南',,,,'北',,,,'East',,,,'南',,,,'West'});爆炸= {};标签= {'e',,,,'n',,,,',,,,'W'};派(x,爆炸,标签)

Now, offset a slice and label all slices.

X= categorical({'北',,,,'南',,,,'北',,,,'East',,,,'南',,,,'West'});爆炸= {'West'};标签= {'e',,,,'n',,,,',,,,'W'};派(x,爆炸,标签)

输入参数

全部收缩

输入向量或矩阵。

  • 如果X是数字,然后在Xmust be finite.pieignores nonpositive values.

  • 如果X是分类的pieignores undefined elements.

数据类型:double|categorical

偏移切片,指定为数字向量或矩阵,字符向量的单元格数组或字符串数​​组。

  • 如果X是数字,然后爆炸必须是零和数字向量或数字向量和矩阵,与X。真实的(非零)值抵消了饼图中心的相应切片,以便X(i,j)is offset from the center if爆炸(i,j)是非零的。爆炸must be the same size asX

  • 如果X是分类的爆炸可以是类别名称的字符向量的单元格数组或类别名称的字符串数组。pie偏移切片对应于类别爆炸

  • 如果X是分类的爆炸也可以是逻辑或数字向量,其元素与与每个类别相对应的元素X。Thepiefunction offsets slices corresponding to true (nonzero) in category order.

切片的文本标签,指定为字符向量或字符串数​​组的单元格数组。

轴对象。利用斧头用特定轴而不是电流轴绘制饼图(GCA)。

输出参数

全部收缩

补丁和文本对象,作为一个向量返回。

扩展功能

Introduced before R2006a

Was this topic helpful?