How can I place a linear plot on top of a surface plot?
20 ビュー (過去 30 日間)
古いコメントを表示
I would like to know how to place a linear plot on top of a surface plot.
採用された回答
MathWorks Support Team
2010 年 9 月 1 日
When you plot a linear plot on top of a surface plot, the linear plot disappears because both the surface plot and linear plot are located in the XY-plane (Z = 0). Hence, neither plot is actually on top. To avoid this issue, place the
surface plot at a -Z offset. For example, execute the following commands:
x = peaks;
h = surface(x);
hold on
z = get(h,'ZData');
set(h,'ZData',z-10)
plot(1:50,'color','r','linewidth',3)
The above code moves the surface plot by 10. You will be able to see the linear plot on the top of the surface plot now.
In the second scenario where instead of lowering the surface plot the line needs to be drawn in raised plane, a similar technique as above can be employed.
Following code first plots the surface and then draws a line in plane Z = max value in the surface plot so that the line sits on top of the surface.
x = peaks;
h = surface(x);
hold on
z_max = max(max(get(h,'Zdata')))
line(1:50,1:50,z_max*ones(1,50))
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!