File Exchange

image thumbnail

Polar 2

version (3.86 KB) by Daniel Armyr
An update to Matlabs built-in polar.m


Updated 01 Sep 2016

View Version History

View License

A polar plot script that allows selection of axis limits by the user, including negative radial limits. It is particularly appropriate for logarithmic data.
A known limitation is that datapoints outside the radial limits will still be drawn.

Cite As

Daniel Armyr (2021). Polar 2 (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (35)

Bang Leo

Thank you very much!

Dávid Földvári

qq shi


Hi Daniel,

Thanks for your work. It really helped a lot.
How can I have theta lines draw at a 45-degree angle rather than 30 degrees?
Also, how can I display a semi-circular plot rather than 360 degrees?
Thanks in Advance.

Dao Duy-Toan

mat bst

Something wrong with the file, it just contains the license.txt file!!!

Cheng Li

Hi, I just downloaded this file, but it is in .zip format and I cannot expand it.. Can someone tell me what should I do? Thanks

Jaroslaw Tuszynski

That was exactly what I needed


A very nice improvement compared to the orignial polar plotter! Though I have a problem:

When ever I try to plot multiple traces with radial limits in one figure, the colour is always blue.

example code:
polar2([0:2*pi; 0:2*pi]', [1:7 ; 7:-1:1]',[0 10])

Have any ideas to why?

Vadim Smolyakov


If there /is/ to be an updated version of polar2.m at any point, it would be fantastic if it could also give the user control over the number and or spacing of the rho-axis gridlines... something akin to the 'ytick' parameter in cartesian axes. Thanks again!


Wow -thanks Daniel, I look forward to any updates that may be available!

Daniel Armyr

OK, I wrote an updated version that incormporates your ideas, Peter. However, as I am now a MathWorks employee, there might be issues with me publishing that update. I will comment again when and if an update is released.

Daniel Armyr

These are limitations in the current version of polar2, yes. But they are not limitations that are more complex than that maybe I can fix them tomorrow.


Daniel - Thanks for filling the polar plot gap for those of us who work with dB attenuation. I've been using your older 'pp.m' for several years now. Despite it's girth and bugginess, I've come to love the control it grants over the graphical aspects of the plot, such as 'ThetaStartAngle' and 'ThetaDirection'.

I'm working on creating a GUI with a polar plot in it. Reading through the comments on the 'pp' page, I gather that we can't use pp to plot into existing axes (or subplots, for that matter), hence 'polar2.'

So, now I can plot my polar into the axes of my choice - Great! But, I seem to lose control over the orientation of the polar coordinate system and the theta direction. Is there a way to set 0 degrees at the top of the plot and plot clockwise?

Additionally, it appears that rho values that are more negative than the 'CenterValue' aren't truncated, as with pp.m. Instead, they appear to be plotted 'through' the center of the plot, 180 degrees off. in pseudo-code,

if rho < CenterValue
plot( (theta - pi), (CenterValue - rho) )

Is this a fundamental limitation in polar2, or is there a workaround (other than setting CenterValue < min(rho) )?


Daniel Armyr

Well, you should be able to use the polar2(AX,...) syntax. I haven't tried it, but if that works wit the original polar, it should work with polar2.

It is always better if you can send the axes as an argument to the function rather than to first set the axes and then plotting. In GUIs, things can happen that change the CGA even between two lines of code in the same function.


Daniel, thank you very much. The answer is similar a your piece of advice. I do:


I have written a lot about set, get, gcf,gca... and now I have just got the answer! :)


The thing that I would like to know is how draw in the graphical user interface GUIDE, how programm my axes (objects handles).

I have two axes in my graphical user interface: PH and PV.

With polar is:
(theta=ang, rho=va)

How is with polar2?

Daniel Armyr

If I understand you correctly, this is what you would do:

subplot ( 2, 1, 1 );
polar2((1:360)*pi/360,-60*rand(1,360),[-60 0])
subplot ( 2, 1, 2 );
polar2((1:360)*pi/360,-60*rand(1,360),[-60 0])


Hello Daniel,
I have written you a pp.m. If I have understood you good, I writte you here. In my GUI I have two axes where I want to draw a radiation pattern (planes horizontal and vertical). The values are negative y therefore I want to use polar2.m. How can I draw in my axes? For example:




Daniel Armyr

@senthil: I am sorry, but I do not udnerstand your question. You seem to have an idea of what your theta values shoudl be. In that case, can't you just set your theta values to what you want and plot it?


I am using ur polar2.m file for plotting. If i have some 2000 rho values in set A, Is it possible to push the data (theta) to start from say 700 to 2700. so i the initial part will be blank. This i need to do (by hold ON) on 4 set of values that will be over laid. so finally i will get concentric ring of values while the central 700 region is empty.

Daniel Armyr

@Faisal: Two examples are provided here in the thread. Try Judy's and Jerrys examples and see where that leads you.


mr daniel, can u send ur demo on this case..

i have case, and im using ur formula, but... the result i have is strange..
i mean the figure result its not logic to me...

Jerry Gump

Solution to my question is:

patch(get(h,'XData'),get(h,'YData'),[0 1 1]);
hold on;
t = 0:.01:2*pi;

Daniel Armyr

@Jerry: Sorry, there are few options for polar plotting in Matlab. Maybe if you ask in the newsgroup you might find something.

Jerry Gump

Do we have anything that works similar to shade command for rectangular plots? We am making a polar plot and I want to shade the region between the two angles.

Daniel Armyr

@Judy: Well, actually. This is the Mathworks original polar.m with just a few modifications to get the features I wanted. So unfortunately, I can't answer for that part of the code since I didn't write it.


Actually, looking into this more, this actually does plot the graph, but the error keeps coming up, so I just commented the last part out. I don't think it is necessary? What was the purpose for making the mcode at the end? Thank you!!

Daniel Armyr

I redownloaded the code from here, and cut and pasted your two-line example directly into my command window. I get a nice flower-petal plot with no errors.

This file has only been tested with Matlab2009a and 2009b. What version are you running?


The code is giving me an error of

??? Error using ==> makemcode>local_parse_input
Invalid input

Error in ==> makemcode at 38
[h,options] = local_parse_input(varargin{:});

Error in ==> polar2 at 249

when I try to plot a simple example for a polar plot with
t = 0:.01:2*pi;

What is going on?

Claudio Pedrazzi

I was looking exactly for this! It is strange that the "polar" function supplied by MATLAB does not provide the facility to set the axis limits. Thanks a lot!

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!