Ezpolar绘制极轴上的函数串(Ezpolar plots function string over polar axes)

编程入门 行业动态 更新时间:2024-10-27 13:32:00
Ezpolar绘制极轴上的函数串(Ezpolar plots function string over polar axes)

我正在使用Ezpolar函数来绘制一些图形。 其中三个最大值为4,但最后一个只有两个以上。

当我绘制它们时,最后一个绘制它的功能(看起来如果ezpolar在将ezpolar值用作半径后绘制一些像素)。

代码和生成的图

% This subplot is used since I've 4 graphics to draw. subplot(2,2,4) ezpolar('0.25*(5 - 4*cosd(-180 * sin(t) ))'); title('D')

Code and Generated Plot

% This subplot is used since I've 4 graphics to draw. subplot(2,2,4) ezpolar('0.25*(5 - 4*cosd(-180 * sin(t) ))'); title('D')

If I don't use this subplot, using a complete figure to draw the graphics seems fine. However, since I need to have all four of them together, it results in (will draw only the problematic one, subplot 2,2,4):

As you can see, r = 0.25 (5 - 4...) is plotted just over the polar axes.

Why is it happening? How can I fix it?

最满意答案

问题似乎在于该注释的位置以及当您使用subplot ,极坐标图的半径上的限制实际上会发生变化,但注释的位置却没有

为了解决这个问题,您实际上可以计算轴的极限并将文本的位置更改为明确地在绘图之外。

hax = subplot(2,2,4); p = ezpolar('0.25*(5 - 4*cosd(-180 * sin(t) ))'); % Get the handle to the label text object label = findobj(hax, 'type', 'text'); % Figure out the current axes limits ylims = get(hax, 'ylim'); % Add some padding (as a percent) to the position padding = 0.2; set(label, 'Position', [0 ylims(1)*(1 + padding), 0]);

在此处输入图像描述

更好的方法是将标签的Units更改为使用Normalized单位(相对于轴)而不是Data单位。 这样,如果轴限制发生变化,它就不会改变。

hax = subplot(2,2,4); p = ezpolar('0.25*(5 - 4*cosd(-180 * sin(t) ))'); % Get the handle to the label text object label = findobj(hax, 'type', 'text'); set(label, 'Units', 'Normalized', 'Position', [0.5, -0.2]);

The issue appears to be with the position of that annotation and the fact that when you use a subplot, the limits on the radius of the polar plot actually change but the position of the annotation does not.

To combat this, you could actually compute the limits of the axes and change the position of the text to be explicitly outside of the plot.

hax = subplot(2,2,4); p = ezpolar('0.25*(5 - 4*cosd(-180 * sin(t) ))'); % Get the handle to the label text object label = findobj(hax, 'type', 'text'); % Figure out the current axes limits ylims = get(hax, 'ylim'); % Add some padding (as a percent) to the position padding = 0.2; set(label, 'Position', [0 ylims(1)*(1 + padding), 0]);

enter image description here

A better way to do this would be to change the Units of the label to use Normalized units (relative to the axes) rather than Data units. This way, it will not change if the axes limits change.

hax = subplot(2,2,4); p = ezpolar('0.25*(5 - 4*cosd(-180 * sin(t) ))'); % Get the handle to the label text object label = findobj(hax, 'type', 'text'); set(label, 'Units', 'Normalized', 'Position', [0.5, -0.2]);

更多推荐

本文发布于:2023-08-03 05:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1384102.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   plots   Ezpolar   极轴上   polar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!