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.

Daniel Armyr (2021). Polar 2 (https://www.mathworks.com/matlabcentral/fileexchange/23589-polar-2), MATLAB Central File Exchange. Retrieved .

Created with
R2012a

Compatible with any release

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

Start Hunting!Create scripts with code, output, and formatted text in a single executable document.

Bang LeoThank you very much!

Dávid Földváriqq shiDave_ImmortalHi 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.

Dave

Dao Duy-Toanmat bstSomething wrong with the file, it just contains the license.txt file!!!

Cheng LiHi, 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 TuszynskiThat was exactly what I needed

LinusA 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 SmolyakovPeterIf 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!

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

Daniel ArmyrOK, 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 ArmyrThese 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.

PeterDaniel - 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) )?

Thanks!

Daniel ArmyrWell, 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.

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

axes(handles.PH)

polar2(...)

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

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

polar(handles.PH,ang,va);

(theta=ang, rho=va)

How is with polar2?

Daniel ArmyrIf I understand you correctly, this is what you would do:

<code>

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])

</code>

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

polar2(handles.PH,(1:360)*pi/360,values,'MaxValue',0,'CentreValue',-60))

christophe7ate9JochenDaniel 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?

senthilI 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.

Faisalmr 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 GumpSolution to my question is:

angle=[0.03*pi:0.01*pi:0.25*pi];

radius=ones(size(angle));

radius(1)=0;radius(size(angle))=0;

h=polar(angle,radius,'g');

patch(get(h,'XData'),get(h,'YData'),[0 1 1]);

hold on;

t = 0:.01:2*pi;

polar(t,sin(2*t).*cos(2*t),'r')

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 GumpDo 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.

JudyActually, 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@Judy:

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?

JudyThe 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

makemcode('RegisterHandle',cax,'IgnoreHandle',q,'FunctionName','polar');

when I try to plot a simple example for a polar plot with

t = 0:.01:2*pi;

polar2(t,sin(2*t).*cos(2*t))

What is going on?

Claudio PedrazziI 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!