Overlay curves on an existing surface plot
50 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Del
el 17 de Mzo. de 2013
Editada: Walter Roberson
el 19 de Mayo de 2019
How to add/overlay curves on an existing plot that was done by a surf() function? I have tried doing that before, but some of the curves are totally lost in the blue colors of my surf()plot.
I read somewhere that I could use "plot3()" BEFORE using surf(), however, my plots are in 2-D (I am using view(2), because I just want to obtain the Feasible region), and I am not quite sure how to use plot3() in this case. Any idea?
1 comentario
Torbjörn Pettersson
el 16 de Mayo de 2019
You are correct the it is good to use plot3. If you do this before or after you have generated the surf do not matter (I normaly di it after the surf).
The command plot3 adds the z to the ploted line/point, and you need to set the "z" value higher than maximum z in the data you use in the surf.
I will give the following code as an example showing the difference between plot and plot3 together with surf.
[X,Y,Z] = peaks(25);
figure
surf(X,Y,Z);
view(2), shading interp
hold on
plot([-3 3],[0 0], 'k-')
plot3([-3 3],[0.25 0.25],[25 25], 'b-')
The black line from the plot command will not be visible. But the plot3 shows on top when I use 25 for z.
Respuesta aceptada
Walter Roberson
el 17 de Mzo. de 2013
Editada: Walter Roberson
el 19 de Mayo de 2019
plot() pretty much creates lines with Z coordinate 0. surf() is going to be using 3D coordinates. Unless your surface happens to be below z 0, your plot lines will be below (at least part of) the surface.
If you want to draw lines right on the surface, then you would need to use z coordinates appropriate for each location when you constructed the line. If your line is a coarser resolution than your surface, this might require interpolating the line at each grid location in order to get the z right for each place.
What you might possibly find easier is to use texture mapping of an image containing the lines, onto the surface. This approach won't be much fun either, though.
Anyhow, remember: if there are two objects both in 3D space, then the object that is closer to the eye is the one that is going to be visible. (lines are implicitly 3D space even when using plot() instead of plot3())
If two three-space are equally close to the eye, then the precedence depends on which renderer you are using. zbuffer and painters will render in order, newest object on top. opengl, however, will ignore the order, and is defined to render lines and surfaces in a particular order (and you'll probably want the exact opposite order at some point... which might be what your graphics driver gives to you as some exactly reverse the defined order!)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!