Axes of polar plot
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
alberto tonizzo
el 15 de Ag. de 2022
Comentada: alberto tonizzo
el 16 de Ag. de 2022
Hi,
I'm plotting a contour plot on top of a polar plot but I can't see the axes (rho?) underneath the contour plot. Does anyone know how to do that?
The code I'm using and the generated figure are below.
Thank you!
% Creating mesh
[phi_HL_upwelling_Mesh,theta_HL_upwelling_Mesh]= meshgrid(deg2rad(phi_HL_upwelling),(theta_HL_upwelling));
% Convert to Cartesian
x = (180 - theta_HL_upwelling_Mesh).*cos(phi_HL_upwelling_Mesh);
y = (180 - theta_HL_upwelling_Mesh).*sin(phi_HL_upwelling_Mesh);
% 2D matrix
z = squeeze(rrs_upwelling(i_st,:,:,i_lambda));
h = polar(x,y);
hold on;
contourf(x,y,z);
set(h,'Visible','off');
axis image;
2 comentarios
Respuesta aceptada
Walter Roberson
el 16 de Ag. de 2022
%when you use polar() the lines are given hidden handles
ax = gca;
LL = setdiff(findall(ax, 'Type', 'line'), ax.Children);
You can now proceed to set ZData on each member of LL to something that is above the contourf plot. Some of the entries in LL will have only 2 data points,
For example,
zoff = 10;
set(LL, {'ZData'}, cellfun(@(C) C*0 + zoff, {LL.XData}, 'uniform', 0).')
The content of the XData is multiplied by 0, to give a zero vector the same size; zoff is added to give a constant vector.
It could instead have been coded as
zoff = 10;
set(LL, {'ZData'}, cellfun(@(C) zoff*ones(size(C)), {LL.XData}, 'uniform', 0).')
Using the property name inside a cell array is a trick that is not well documented. set() allows you to set multiple properties at once, or set properties for multiple objects, if you use a cell array for the property name(s)
3 comentarios
Walter Roberson
el 16 de Ag. de 2022
The circles can be generated as a patch() object in the case where the axes color is not a character (I can't say I understand that part.) It might perhaps make sense to look for a patch with findall() and if it exists then to explicitly set ZData for it -- even if you set it to 0. 2D objects interact oddly with 3D objects sometimes.
Más respuestas (0)
Ver también
Categorías
Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!