Search code examples
matlabplothistogrampolar-coordinates

Fixing the Radial Axis on MATLAB Polar Plots


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

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

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


Solution

  • 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:

    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.