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;
댓글 수: 2
채택된 답변
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!