How to “color” the first curve moving across x-axis in a 3D surface plot?
2 views (last 30 days)
Show older comments
Hi there! I’d like to “color” the first curve in my 3D surface plot differently from the colormap colors, say, black, to contrast nicely with the “cool” colormap colors. How can I best do this? Namely, I want to underlay the surface with a plot3( ) line plot, then find that first curve, then make it black. I was able to do this, writing set(h1(1),‘k’), but the wrong curve gets colored: the first curve going towards the y-axis, when I want to color the curve moving across the x-axis. Thanks in advance.
0 Comments
Accepted Answer
Animesh
on 4 Jan 2025
Edited: Animesh
on 4 Jan 2025
Hey @Noob
It seems that you want to color the first curve along the "x-axis" in a 3D surface plot. Here is something you can try:
1. Plot the Surface: Use "surf(X, Y, Z)" to create your surface plot with the desired colormap.
2. Extract the Desired Curve: To get the curve along the "x-axis" (first row of Y), extract the first row of your matrices:
x_curve = X(1, :);
y_curve = Y(1, :);
z_curve = Z(1, :);
3. Overlay the Curve: Use "plot3" to overlay the extracted curve in black:
hold on;
plot3(x_curve, y_curve, z_curve, 'k', 'LineWidth', 2); % Black line with desired thickness
shading interp
hold off;
You can refer to the following MathWorks documentation for more information on "plot3" function:
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!