To create Polar Shaded plot
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Utsav
el 21 de Mzo. de 2016
Comentada: Utsav
el 22 de Mzo. de 2016
X,Y,Z DATA ..all n*1 array
X is angle, with NEWS convention, Y is radius, Z is data.
I need shaded plot of data, onto a polar plot of radius information in Y angle information in X and data information in Z
Basically a rose plot sans the discreet histogram.
Sorry cant figure out any solution.
2 comentarios
Joachim Schlosser
el 21 de Mzo. de 2016
Could you please go to https://de.mathworks.com/products/matlab/plot-gallery.html and give the closest resemblance of what you need?
Respuesta aceptada
Mike Garrity
el 22 de Mzo. de 2016
Editada: Mike Garrity
el 22 de Mzo. de 2016
If you don't see a polar plot which does what you want, you can use the pol2cart function to get to any of the Cartesian techniques, such as the ones I described in this blog post.
% Made up data
npts = 200;
theta = 2*pi*rand(npts,1);
r = rand(npts,1);
v = cos(theta) .* sin(pi*r);
% Convert to cartesian
[x,y] = pol2cart(theta,r);
% Interpolate onto grid
[xg,yg] = meshgrid(linspace(-1,1,125));
F = scatteredInterpolant(x,y,v);
% Mask out extrapolation
b = boundary(x,y);
inmask = inpolygon(xg(:),yg(:), x(b),y(b));
vg = F(xg,yg);
vg(~inmask) = nan;
% Call pcolor
polar(nan,nan)
hold on
h = pcolor(xg,yg,vg);
h.EdgeColor = 'none';
colorbar

3 comentarios
Mike Garrity
el 22 de Mzo. de 2016
First, I'm afraid I cut & pasted the wrong version when I saved that answer the first time, so you'll want to get the updated version. I left out the call to polar the first time!
For moving the 0 angle, you really want the new polarplot function as I talked about in this blog post. The problem is that it doesn't really work with this pol2cart trick, so I don't think that's going to work for you.
As for the grid lines being behind the pcolor, that's because I added the pcolor object last. To fix this, you need to move it down in the list. It is possible, but it's rather hacky. It look something like this:
% Made up data
npts = 200;
theta = 2*pi*rand(npts,1);
r = rand(npts,1);
v = cos(theta) .* sin(pi*r);
% Convert to cartesian
[x,y] = pol2cart(theta,r);
% Interpolate onto grid
[xg,yg] = meshgrid(linspace(-1,1,125));
F = scatteredInterpolant(x,y,v);
% Mask out extrapolation
b = boundary(x,y);
inmask = inpolygon(xg(:),yg(:), x(b),y(b));
vg = F(xg,yg);
vg(~inmask) = nan;
% Call polar & pcolor
polar(nan,nan)
hold on
h = pcolor(xg,yg,vg);
h.EdgeColor = 'none';
uistack(h,'down',29)
colorbar

That 29 in the call to uistack is a magic number involving the number of grid lines and labels, and you'd probably need to fiddle with it.
If you're really going to need a lot of customizing, you'd probably be better off looking at some of the polar functions on the file exchange. For example, this one looks like it might be a good starting point, but I've never tried it.
Más respuestas (0)
Ver también
Categorías
Más información sobre Polar Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!