Axes of polar plot
4 ビュー (過去 30 日間)
古いコメントを表示
alberto tonizzo
2022 年 8 月 15 日
コメント済み: alberto tonizzo
2022 年 8 月 16 日
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!