我正在使用rose2.m生成许多角度直方图。我希望显示每个仓位中的元素数量的比例范围在0-50之间,增量为10,对于所有绘图,即使特定绘图上的最大元素数量小于50。有谁知道我该怎么做吗?谢谢。
发布于 2012-06-29 02:55:59
这个问题与this one相同,但您看到的是rose2的一个特例。
我能够使用以下代码将最大值锁定为50。首先,我在50处绘制一个空点,然后使用hold on锁定该图。然后,rose2使用这些界限。
代码:
x = (rand(100,1)*pi);
maxHistogramValue = 50;
figure(44);
clf
% Set the max value to maxHistogramValue:
polar(0, maxHistogramValue,'-k')
hold on;
% Now use rose2:
rose2(x);发布于 2012-06-29 10:24:31
下面是另一个例子(基于@Steve的想法):
%# data and angular histogram
x = rand(400,1) .* 2*pi;
[t,r] = rose(x); %# this does not generate a plot
%# set plot's max radial ticks
figure
rMax = 50;
h = polar(0, rMax);
delete(h)
set(gca, 'Nextplot','add')
%# draw patches instead of lines: polar(t,r)
[x,y] = pol2cart(t,r);
h = patch(reshape(x,4,[]), reshape(y,4,[]), 'b');
alpha(h, 0.5) %# note: this switches to OpenGL renderer

这样你就可以控制最大半径,尽管你不能真正控制步数(极性函数总是偏爱5个径向刻度;见源代码)。
发布于 2012-06-29 02:57:17
我不完全清楚rose2.m是什么,但我想你可以设置你自己的比例/图例,如果你有必要的数据的话。
听起来你有一个角度的数组/向量,范围在0到50之间。我们暂时将其命名为angleArray。
要获得落入每个bin中的元素数量( 10个单位内的0-50),您可以使用以下代码行:
binCounts = histc(angleArray, 0:10:50);binCounts将是1乘以n,其中n是长度(0:10:50),并且具有每个bin的值数的计数。然后,这些数据可以用来填充您的天平。
https://stackoverflow.com/questions/11250166
复制相似问题