Axes of polar plot
4 次查看(过去 30 天)
显示 更早的评论
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;
采纳的回答
Walter Roberson
2022-8-16
%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 个评论
Walter Roberson
2022-8-16
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!