【问题标题】:MATLAB rose plot: increasing radial increments?MATLAB玫瑰图:增加径向增量?
【发布时间】:2012-06-28 17:47:00
【问题描述】:

我正在使用rose2.m 制作许多角度直方图。我希望显示每个箱中元素数量的比例范围在 0-50 之间,以 10 为增量递增,对于所有地块,即使特定地块上的最大元素数小于 50。有谁知道如何请问我可以这样做吗?谢谢。

【问题讨论】:

标签: matlab graphics plot histogram polar-coordinates


【解决方案1】:

此问题与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);

【讨论】:

    【解决方案2】:

    这是另一个例子(基于@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
    

    这样你就可以控制最大半径,虽然你不能真正控制步数(POLAR 函数总是喜欢大约 5 个径向刻度;请参阅源代码)。

    【讨论】:

      【解决方案3】:

      我不完全清楚rose2.m 是什么,但我想如果您有必要的数据,您可以设置自己的比例/图例。

      听起来您有一个角度数组/向量,范围在 0 到 50 之间。我们现在将其称为 angleArray。

      要获取落入每个 bin 的元素数量(0-50,每 10 个单位增量),您可以使用以下代码行:

      binCounts = histc(angleArray, 0:10:50);
      

      binCounts 将是 1 x n,其中 n 是长度 (0:10:50),并且具有每个 bin 的值的数量的计数。然后可以使用该数据来填充您的量表。

      【讨论】:

        猜你喜欢
        • 2014-07-02
        • 2015-11-08
        • 2013-06-02
        • 2022-01-21
        • 2022-12-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-08-28
        相关资源
        最近更新 更多