[英]Pie Chart Using Raw Data
I have 4 types of objects with labels 1,2,3 and 4. 我有4种类型的对象,分别带有标签1,2,3和4。
Now, I have N
objects as a vector of Nx1
where each element corresponds to the class of the object. 现在,我有
N
对象作为Nx1
的向量,其中每个元素对应于对象的类。
So, if I have 5
objects, I might have a vector that looks like 因此,如果我有
5
对象,那么我的向量可能看起来像
D = [1,1,3,4,2]
What I want to do is the get a pie chart for the data D
. 我要做的是获取数据
D
的饼图。 A hotch-potch way of doing it is: 一种可行的方式是:
count_data = zeros(4,1);
for it=1:4
count_data(it) = sum(D==it);
end
pie(count_data)
Is there a clean way of doing this? 有一种干净的方法吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.