简体   繁体   English

Matlab:明确指定饼图切片颜色

[英]Matlab: Explicitly specifying pie graph slice color

I'm creating a pie graph. 我正在创建一个饼图。

pie([a,b,c,d]);

Is it possible to explicitly change the color of the individual slices? 是否可以明确更改单个切片的颜色?

For example; 例如; if I wanted the slices for a and b to always be green and c and d to always be blue, regardless of their size, how would I do that? 如果我想让a和b的切片始终为绿色而c和d总是为蓝色,无论它们的大小如何,我该怎么做? It seems to me that a color map shades using the size of the slice not necessarily the order in which it was given to the pie function. 在我看来,使用切片大小的颜色图阴影不一定是它给饼图函数的顺序。

The colors of the pie are determined by the axis colormap. 饼图的颜色由轴色图确定。 So define a matrix with as many rows as the number of pie wedges, and use that as colormap. 因此,定义一个矩阵,其行数与饼图楔数一样多,并将其用作颜色图。 The first color refers to the first value ( a ), etc. 第一种颜色是指第一个值( a )等。

For example: 例如:

pie([3 2 4 1])
colormap([1 0 0;      %// red
          0 1 0;      %// green
          0 0 1;      %// blue
          .5 .5 .5])  %// grey

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM