필터 지우기
필터 지우기

Multi Surface Plotting & Color Control of each surface

조회 수: 18 (최근 30일)
Julia Hoskins
Julia Hoskins 2021년 4월 14일
댓글: Chad Greene 2021년 4월 15일
My code, shown below, plotting two surfaces in the same figure functions properly.
%Plotting
figure(1)
[A1,B1] = meshgrid(X1, Y1);
Za = griddata(X1,Y1,Z1,A1,B1);
surf(A1, B1, Za)
hold on
[A2,B2] = meshgrid(X2, Y2);
Zb = griddata(X2,Y2,Z2,A2,B2);
surf(A2, B2, Zb)
grid on
title('Surface Plots')
legend({'1','2'});
set(gca, 'ZLim',[0 8.5])
shading interp
hold off
But I am trying to designate separate color patterns to each surface in the figure and no method I've tried works. Designating colormaps in various locations only colors all plots as the last color map declared and formating each surface plot with the surf(X,Y,Z,C) command hasn't worked with any of the color commands I know. Color map specifications or 'r', 'b', 'g' types.
Any other suggestions or if anyone has done this, I'd love some help?

답변 (1개)

Chad Greene
Chad Greene 2021년 4월 14일
편집: Chad Greene 2021년 4월 14일
Try setting the facecolor option using the RGB values. Here are a red [1 0 0] and a blue [0 0 1] surface, using built-in example data:
[X,Y,Z] = peaks(500);
figure
view(3)
hold on
h1 = surf(X,Y,Z);
h1.EdgeColor = 'none'; % gets rid of lines
h1.FaceColor = [1 0 0];
h1.FaceAlpha = 0.8; % optional transparency
h2 = surf(X,Y,Z+5);
h2.EdgeColor = 'none';
h2.FaceColor = [0 0 1];
h2.FaceAlpha = 0.8;
camlight % turns on lighting
  댓글 수: 2
Julia Hoskins
Julia Hoskins 2021년 4월 15일
I tried and it's still showing the default color map.
Chad Greene
Chad Greene 2021년 4월 15일
Can you provide a minimal working example that replicates the problem?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by