固定 MATLAB 极坐标图上的径向轴

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/226315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:40:53  来源:igfitidea点击:

Fixing the Radial Axis on MATLAB Polar Plots

matlabplothistogrampolar-coordinates

提问by Adam Holmberg

I'm using polar plots (POLAR(THETA,RHO)) in MATLAB.

我在 MATLAB 中使用极坐标图 (POLAR(THETA,RHO))。

Is there an easy way to fix the range for the radial axis to say, 1.5?

是否有一种简单的方法可以将径向轴的范围固定为 1.5?

I'm looking for something analogous to the xlim, ylim commands for cartesian axes. Haven't found anything in the docs yet.

我正在寻找类似于 xlim, ylim 命令的笛卡尔坐标轴的东西。尚未在文档中找到任何内容。

采纳答案by Tim Whitcomb

Here's how I was able to do it.

这就是我如何做到的。

The MATLAB polar plot (if you look at the Handle Graphics options available) does not have anything like xlim or ylim. However, I realized that the first thing plotted sets the range, so I was able to plot a function with radius range [-.5 .5] on a [-1 1] plot as follows:

MATLAB 极坐标图(如果您查看可用的 Handle Graphics 选项)没有 xlim 或 ylim 之类的内容。但是,我意识到绘制的第一件事设置了范围,因此我能够在 [-1 1] 图中绘制半径范围为 [-.5 .5] 的函数,如下所示:

theta  = linspace(0,2*pi,100);
r      = sin(2*theta) .* cos(2*theta);
r_max  = 1;
h_fake = polar(theta,r_max*ones(size(theta)));
hold on;
h      = polar(theta, r);
set(h_fake, 'Visible', 'Off');

That doesn't look very good and hopefully there's a better way to do it, but it works.

这看起来不太好,希望有更好的方法来做到这一点,但它有效。

回答by Adam Holmberg

this worked for me... i wanted the radius range to go to 30, so i first plotted this

这对我有用......我希望半径范围达到 30,所以我首先绘制了这个

polar(0,30,'-k')
hold on

and then plotted what i was actually interested in. this first plotted point is hidden behind the grid marks. just make sure to include

然后绘制我真正感兴趣的内容。第一个绘制的点隐藏在网格标记后面。只要确保包括

hold off

after your final plotting command.

在您的最终绘图命令之后。

回答by Ayesha Hakim

Simple solution is to make a fake graph and set its color to white.

简单的解决方案是制作一个假图并将其颜色设置为白色。

fake=100;
polar(0,fake,'w');
hold on;

real=10;
polar(0,real,'w');

回答by CalPolyAero

In case anyone else comes across this, here's thesolution:

万一其他人遇到这个问题,这里解决方案:

As Scottie Tand gnovicepointed out, Matlab basically uses the polar function as an interface for standard plots, but with alot of formatting behind the scenes to make it look polar. Look at the values of the XLim and YLim properties of a polar plot and you'll notice that they are literally the x and y limits of your plot in Cartesian coordinates. So, to set a radius limit, use xlim and ylim, or axis, and be smart about the values you set:

正如Scottie Tgnovice 所指出的那样,Matlab 基本上使用 polar 函数作为标准绘图的接口,但在幕后进行了大量格式化以使其看起来是 polar 。查看极坐标图的 XLim 和 YLim 属性的值,您会注意到它们实际上是您的图在笛卡尔坐标系中的 x 和 y 范围。因此,要设置半径限制,请使用 xlim 和 ylim 或轴,并对您设置的值保持谨慎:

rlim = 10;
axis([-1 1 -1 1]*rlim);

...that's all there is to it. Happy Matlabbing :)

...这里的所有都是它的。快乐的 Matlabbing :)