How can I place a linear plot on top of a surface plot?
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I would like to know how to place a linear plot on top of a surface plot.
Akzeptierte Antwort
MathWorks Support Team
am 1 Sep. 2010
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!