【问题标题】:Change properties of rose plot更改玫瑰图的属性
【发布时间】:2023-01-16 22:50:53
【问题描述】:

我在我的脚本中使用函数 rose2 来绘制玫瑰图。我正在使用 Matlab 2016a,因此仍然使用 rose 函数。我使用 rose2 以便能够设置 r 轴的最大值并填充三角形。 我使用“findall”来旋转 R 轴标签的位置。 这非常有效:

maxHistogramValue = 100;

f=figure;

clf

% Set the max value to maxHistogramValue:

polar(0, maxHistogramValue,'-k')

% Set the location of the R-axis labels in degrees.
% Extract all of the 'Text' objects from the polar plot.
ax = findall(f.Children, 'Type', 'Axes');
% Filter the 'Text' objects by the 'HorizontalAlignment' property.
% PLEASE NOTE: This may not generalize to other versions of MATLAB
% where the default 'HorizontalAlignment' value for R-axis labels is not
% set to 'left'.
labels = findall(ax, 'Type', 'Text', 'HorizontalAlignment', 'left');
% Set the degrees of the R-axis Labels.
degrees = 285;
% Update the position of each R-axis label.
for label = labels'
    currentX = label.Position(1);
    currentY = label.Position(2);
    radius = sqrt(currentX^2 + currentY^2);
    newX = cos(degtorad(degrees)) * radius;
    newY = sin(degtorad(degrees)) * radius;
    label.Position = [newX, newY];
end

hold on;

% Now use rose2:

rose2(inp, theta_rad)

%make transparent
alpha(0.5)

view(-90,90)

我想出了如何通过以下方式更改字体大小:

labels = findall(ax, 'Type', 'Text');
for label = labels'
    label.FontSize = 16;
end 

但我想用度数符号显示角度。 我试图将它添加到循环中,但首先,显示了奇怪的数字,其次,它还更改了 r 轴,这当然是我不想要的。

labels = findall(ax, 'Type', 'Text');
for label = labels'
    label.FontSize = 16;
    label.String=label.String+char(176);
end

有人可以帮忙吗???

谢谢!

【问题讨论】:

    标签: matlab matlab-figure axes rose-plot


    【解决方案1】:

    尝试alpha(0.5),在rose2 函数中或在脚本底部,以获得您想要的透明度。

    另外,尝试polaraxes 定义字体大小。

    ax = polaraxes;
    ax.FontSize = 25;
    

    【讨论】:

    • 谢谢! - 在脚本底部定义 alpha 非常有效。 -但我对极轴有疑问。如果我使用你的命令行,这些值会被绘制两次,一次是小的,一次是字体大小 25,并且数据不再被绘制。根据我在脚本中粘贴您的行的位置,我还会收到以下错误: Error using newplot (line 76) Adding Cartesian plot to polar axis is not supported.极坐标错误(第 74 行)cax = newplot(cax); rose2 错误(第 84 行) h = polar(t,r); RosePlot_PAC 错误(第 157 行)rose2(inp, theta_rad)
    • 我希望我能为你提供更多帮助,但我不能:(我不再有 Matlab,所以我无法测试你的代码。
    • 大多数人都可以在这里访问 MATLAB:matlab.mathworks.com
    【解决方案2】:

    如果您查看labels,您会发现它包含更多标签。你只想修改labels(1:12)

    labels = findall(ax, 'Type', 'Text');
    for label = labels(1:12)'
        label.String=[label.String char(176)];
    end
    

    此外,您的 label.String=label.String+char(176); 不是 matlab 语法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-03
      • 2018-07-25
      • 1970-01-01
      • 2022-12-09
      • 1970-01-01
      • 1970-01-01
      • 2015-11-08
      相关资源
      最近更新 更多