[英]Matlab/Octave Pie Chart Categorization
Do you guys know how I can create a pie chart where if a data point is greater than or is less than a value, it is categorized as increase or decrease on the pie chart. 你们知道我如何创建饼图,如果数据点大于或小于某个值,则在饼图上将其归类为增加或减少。 If so, how?
如果是这样,怎么办? for example, if I ran this code:
例如,如果我运行以下代码:
a = 0.4004990132;
b = 1.226695443;
c = 0.01709;
r(1) = 1.3975;
for t = 2:25
r(t) = r(t-1)+a*(b-r(t-1))+c*randn;
end
Could I make it so it creates a pie chart where when r is greater than the r(1)
it gets marked as increase and when it is lower, as decrease. 我能否做到这一点,以便创建饼图,当r大于
r(1)
,将其标记为增加,而当r(1)
小于r(1)
,将标记为减少。 So that the pie chart will be separated by the % of time that there was an increase vs. decrease. 这样饼形图将以出现增加与减少的时间百分比分开。
If you use the example in your question 100% of the values in r(2:end)
are greater than r(1)
, so I generated some other sample data to illustrate the solution to what I think you have been asking: 如果您在问题中使用该示例,则
r(2:end)
中的100%的值大于r(1)
,因此我生成了一些其他示例数据来说明我认为您一直在问的问题的解决方案:
r1 = 0.3; % threshold level
r = rand(25,1); % uniform random values between 0..1
rup = sum(r>r1); % count how many values greater than r1
rdown = sum(r<r1); % count how many values smaller than r1
% plot the precentage as a pie chart:
pie([rup rdown],{sprintf('%2.0f%% Increase',rup/25*100),...
sprintf('%2.0f%% Decrease',rdown/25*100)})
or something like it, since the data is random. 之类的东西,因为数据是随机的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.