How do I create a contour plot in polar coordinates?

조회 수: 116 (최근 30일)
MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
댓글: Walter Roberson 2023년 1월 31일
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.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
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.
  댓글 수: 2
Mike Garrity
Mike Garrity 2015년 3월 4일
You need to pass the x & y arrays into the contourf function. If you don't, it will just use the defaults which go along the X & Y axes.
Walter Roberson
Walter Roberson 2023년 1월 31일
Note:
These days true polar axes are supported; see polarplot .
However that does not mean that polar contour is supported :(

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

제품


릴리스

R2006a

Community Treasure Hunt

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

Start Hunting!

Translated by