Circle plan using plot and pcolor

Hi to all
I am trying to do something special.
I want to superpose a polar with a plot and a pcolor plan but what I want to do is to display it in a big circle (no square at all). It's probably really simple but I can't find a way how.
Because of confidentiality I can't send the entire code but I will show you my "graphic code" so you can all see what I am trying to do.
Here is the code :
h=polar([0 2*pi], [0 50]); delete(h) hold on g=plot(yB,xB,yA,xA,yC,xC,'LineStyle','none') %axis([-50 50 -50 50]) legend('Bob','Alice','Charlie') title('Distribution polaire') xlabel('Distance (m)') ylabel('Distance (m)') hold on [Xeve,Yeve]=meshgrid((yDeb:res:yFin),(xDeb:res:xFin)); pcolor(Xeve,Yeve,(PerrE)); shading interp colorbar axis equal square set(g, 'markersize', 10); set(g,{'color'},{'c';'y';'g'}) set(g, {'markeredgecolor', 'marker'}, {'c' 'o'; 'y' '^'; 'g' 's'}); set(g,{'markerfacecolor'},{'c';'y';'g'}) uistack(g, 'top'); hold off
And here is a picture of the result:
So what I want is essentially no square at all and fit all my "pcolor" inside the circle drawn by polar.
Thank you !!!

 Accepted Answer

My first thought would be to layer two axes on top of each other: one for the polar plot and any line objects that can be plotted on it, and one for the pcolor plot, since the latter isn't supported by any polar plot functions that I know of (though you may want to browse the File Exchange).
Creating the circular pcolor plot is simply a matter of interpolating your data onto a grid that's defined in terms of r/theta rather than x/y.
Also, out of habit I always use mmpolar from the File Exchange instead of polar, because it's much more flexible.
An example:
[x,y] = meshgrid(linspace(-50,50,200));
z = peaks(200);
[r,th] = meshgrid(linspace(0,50,100), linspace(0, 2*pi, 360));
xp = r.*cos(th);
yp = r.*sin(th);
zp = interp2(x,y,z,xp,yp);
ax1 = axes('visible', 'off');
pcolor(xp,yp,zp);
shading flat;
axis equal;
ax2 = axes('position', get(ax1, 'position'));
hp = mmpolar(NaN, NaN, 'RLimit', [0 50], 'backgroundcolor', 'none');
set(ax1, 'visible', 'off');

3 Comments

I understand the principle really well but when it comes to implement it, it really dosen't work. I will explain you my strategy:
1. I found the random R and Theta coordinates of Alice,Bob, and Charlie
2. I converted to cartesian coordinates
3. I did all the necessary operations
4. I want all my results to appear in a polar circle.
So the main problem is that I just can't do this using your strategy because the best graphic I can get is a "twisted" version of the results. It's like I juste kind of "rotate" my results. The graphic I get is the following (for better understanding) :
Hmm, hard to tell exactly what's happening without data. I'm assuming all your data starts in cartesian coordinates, right? The polar plot is just for visualization purposes?
Here's the example with a bit more detail. As you can see, the plots should be identical in polar and cartesian space with the exception of the axis overlay and the cropped pcolor space:
% Original data (in cartesian space)
[x,y] = meshgrid(linspace(-50,50,200));
z = peaks(200);
tmp1 = rand(3,1)*2*pi;
tmp2 = rand(3,1)*50;
xpt = tmp2 .* cos(tmp1);
ypt = tmp2 .* sin(tmp1);
% Plot in cartesian
ax(1) = subplot(1,2,1);
pcolor(x,y,z);
shading flat;
hold on;
plot(xpt, ypt, 'ko');
axis equal tight;
% Convert to polar
[r,th] = meshgrid(linspace(0,50,100), linspace(0, 2*pi, 360));
xp = r.*cos(th);
yp = r.*sin(th);
zp = interp2(x,y,z,xp,yp);
[thpt, rpt] = cart2pol(xpt, ypt);
% Plot in polar
ax(2) = subplot(1,2,2);
pcolor(xp,yp,zp);
shading flat;
axis equal;
ax(3) = axes('position', get(ax(2), 'position'));
hp = mmpolar(thpt, rpt, 'ko', 'RLimit', [0 50], 'backgroundcolor', 'none');
set(ax(2), 'visible', 'off');
Thank you very very much !!! It finally worked. :)
Sorry for the late answer. I work on many things at the same time.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!