MATLAB Answers

How do I create a contour plot in polar coordinates?

581 views (last 30 days)
I would like to create a contour plot on polar axes similar to the plots produced by the POLAR function. My data set is defined in (R, theta) coordinates.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
A function that creates a polar contour plot is not present in MATLAB.
True polar axes are not supported in MATLAB. The POLAR function does the following to create a plot:
1. Accepts polar coordinates
2. Converts the data to Cartesian coordinates and plots them.
3. Draws the polar grid lines and text on a Cartesian axes system.
To create a contour plot in polar coordinates, you will need to follow a similar procedure. The following code shows an example:
% Create polar data
[r,t] = meshgrid(0:.1:5,0:pi/30:(2*pi));
z = r - t;
% Convert to Cartesian
x = r.*cos(t);
y = r.*sin(t);
Next, you can produce the annotations using the POLAR function and create the contour plot:
h = polar(x,y);
hold on;
contourf(x,y,z);
% Hide the POLAR function data and leave annotations
set(h,'Visible','off')
% Turn off axes and set square aspect ratio
axis off
axis image
Some of the annotations may be obscured when the contour plot is drawn. The most reliable way to work around this issue is to manually redraw them using the Plot Tools GUI or the ANNOTATION function.
  5 Comments
Shweta Singh
Shweta Singh on 5 May 2020
Hi Tarkes,
Please reach out to MathWorks Technical Support by using the following link and they will be able to assist you further:
Thanks,
Shweta Singh

Sign in to comment.

More Answers (1)

Chuxi Liu
Chuxi Liu on 31 Oct 2019
Hi,
I successfully created the polar contourf. However, what should I do if I want to adjust the theta direction, radius limit and also the starting position of the theta for the polar axis?
I tried almost all possible methods and couldn't figure it out.
Appreciate your assistance!!!
  1 Comment
Tarkes Dora
Tarkes Dora on 23 Apr 2020
I was able to generate plots. I am looking for assistance in same problem. Any leads in this direction?
Is it possible to control the theta axis in steps of 0:45:360? Any hints
Any suggestion would be of great help!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!