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!