2D polar plot axes & colour legend
8 views (last 30 days)
Show older comments
peter bautmans
on 26 Aug 2019
Commented: Star Strider
on 30 Aug 2019
hi
I'm a fairly new user to MATLAB2016b, and am struggling a bit with 2D polar plots.
I'd like to plot parameter values as a function of inclination (0-90deg) and azimuth (0-360deg) with the 'polar' function. In the polar plot, the radial direction reflects 0-90deg inclination and the tangential direction reflects 0-360deg (with 90deg towards the right).
For some reason the polar function adds a white rim to my figure, i.e. it plots data from 0-100 deg. Can anyone help me get rid of the 90-100 deg inclination section on the plot?
I'd also like to define the colourscale legend with a min and max value; how can that be done?
Attached is the polar plot code i'm using, where 'A' is the input value matrix. The 'A' is attached as an excel sheet, and A(1,1) is in cell 2B.
thanks for any help!
peter
0 Comments
Accepted Answer
Star Strider
on 26 Aug 2019
The matrix in the Excel file does not work with the code you posted (the matrix size is not compatible with the calculated values), so I cannot run it.
Use polarplot (introduced in R2016a, so you should have it) instead of polar. You can restrict the radial axis to the limits you set using the ‘RLim’ property of polarplot.
Example:
a = linspace(0, 2*pi);
r = linspace(0, pi);
figure
polarplot(a, r)
rlim([0, max(r)])
Experiment to get the result you want.
5 Comments
Star Strider
on 27 Aug 2019
Try this for figure(3):
figure(3)
[c_bfm, c_bfm]=contourf(x,y,A',v);
set(c_bfm,'LineStyle','none');
hold on
plot([zeros(1,13); 90*cosd(0:30:360)], [zeros(1,13); 90*sind(0:30:360)],'k')
plot(90*((0:0.33:1)'*cosd(0:10:360))', 90*((0:0.33:1)'*sind(0:10:360))','k')
colorbar
set(colorbar,'FontSize',16)
axis equal
set(gca, 'Box','off', 'XColor','none', 'YColor','none', 'Color','none')
hold off
producing:

I will let you add the radial tick values with the text function.
Adapt this to add them:
figure(3)
[c_bfm, c_bfm]=contourf(x,y,A',v);
set(c_bfm,'LineStyle','none');
hold on
plot([zeros(1,13); 90*cosd(0:30:360)], [zeros(1,13); 90*sind(0:30:360)],'k') % Plot Angle Radials
plot(90*((0:0.33:1)'*cosd(0:10:360))', 90*((0:0.33:1)'*sind(0:10:360))','k') % Plot Radius Circles
colorbar
cbpos = get(colorbar, 'Position');
set(colorbar,'FontSize',16, 'Position',cbpos+[0.05 0 0 0])
fpos = get(gcf, 'Position');
set(gcf, 'Position',fpos+[0 -100 200 100])
axis equal
set(gca, 'Box','off', 'XColor','none', 'YColor','none', 'Color','none')
hold off
xt = 105*cosd(0:30:330);
yt = 105*sind(0:30:330);
tlbls = sprintfc('%3d°', (0:30:330));
text(xt, yt, tlbls)
producing:

Experiment to get the result you want.
More Answers (0)
See Also
Categories
Find more on Polar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!