How to “color” the first curve moving across x-axis in a 3D surface plot?

2 次查看(过去 30 天)

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.

采纳的回答

Animesh
Animesh 2025-1-4
编辑:Animesh 2025-1-4
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:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by