Overlay a spectrum in contourf on top of polar (without the ticks)

9 views (last 30 days)
Hello,
I have a question regarding a contourf plot and polar. For a current project (and I will have to do the same thing for future projects), I have a spectrum that I plotted using contourf. What I need to do is to overlay lines indicating the angles on top of the contourf plot. The problem is that when I just do a polar plot, hold it on and then add my contourf plot, I still have the annoying tick labels from polar.
There are three adjustments that I want to make to the figure for it to be what I need: 1. I need to remove the tick labels of the different angles and of the different circle radii 2. The plot needs to be square instead of circular so that the x axis and y axis match up to the plot. 3. When I save it, the color from the contourf does not save and all I get is a black and white contour plot on top of a polar plot.
figure
polar(thn,rc);
hold on;
contourf(xn,yn,psi5n,12);
hold on;
colorbar;
xminb=-r;
xmaxb=r;
yminb=-r;
ymaxb=r;
xlim([xminb xmaxb]);
ylim([yminb ymaxb]);
xlabel('k (rad/m)','fontsize',14);
ylabel('k (rad/m)','fontsize',14);
formatSpec ='Wave Spectrum time %g hours, location (%g lat, %g lon), WS %g m/s, (min 10 m)';
title(sprintf(formatSpec,tma,latp,lonp,ws),'fontsize',14);
I tried doing the following contour plot followed by hold on, then the polar plot and hold on, and finally the contourf plot. Doing that gave me a nice image, but it did not plot the lines from polar. I simply had the large contour rings with my contourf image on top as if MATLAB ignored the polar part of my code.
[C,h] = contour(xn,yn,kn,cvec,'color','k','LineStyle','--');
Fixing this problem will help me considerably as it will make the image for my project better and come in handy with research.
Thanks.
  4 Comments
Colin
Colin on 8 May 2012
http://www.mathworks.com/matlabcentral/fileexchange/36586-wave-spectrum-radial-plot
This includes the entire code and some of the variables necessary to run it. I have submitted the larger files (the wave spectra which I refer to as psi). These files correspond to 2 dimensional wave spectra from different wind speeds. In each case, the wind speed is uniform and constant from south to north over a 3 degree longitude by 3 degree latitude grid.
Monika
Monika on 23 Feb 2014
Hi! I have a similar problem. This is how my plot looks like in Matlab:
And this is how it saves as .png file:
if true
% code
g = figure;
subplot(1,2,1);
h1 = polar(x,y,'o');
hold on
contourf(X,Y,Z2)
colorbar('location','southoutside')
title('FILLED CONTOUR','FontSize',10)
delete(h1)
subplot(1,2,2);
h1 = polar(x,y,'o');
hold on
contour(X,Y,Z2)
title('CONTOUR','FontSize',10)
colorbar('location','southoutside')
delete(h1)
end
Please HELP! :]

Sign in to comment.

Answers (0)

Categories

Find more on Contour 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!