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 个评论
KSSV
KSSV 2022-8-16
You may draw them manually using line
alberto tonizzo
alberto tonizzo 2022-8-16
I'd rather not doing it manually, I have quite a few plots to make. Thanks.

请先登录,再进行评论。

采纳的回答

Walter Roberson
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
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.
alberto tonizzo
alberto tonizzo 2022-8-16
Would you be able to write a few lines of code? I'm not familiar with patch nor findall.
Thank you so much!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by