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.
0 个评论
采纳的回答
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 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!