Plot multiple surfaces on same plot with different color for each surface
조회 수: 196 (최근 30일)
이전 댓글 표시
Hi. I have to superimpose several surfaces on the same plot, something like:
surf(X1,Y1,Z1); hold on
surf(X2,Y2,Z2); hold on
surf(X3,Y3,Z3); hold on
... etc
This shows all surfaces with the same color scheme. I would like to show each surface with a different color map. Does anybody have suggestions? Many thanks.
댓글 수: 1
Anant Gairola
2016년 11월 13일
I have the same question. Did you find an answer? I have three surface plots, one on each xy, xz and yz planes. I want a different color bar scheme for each surface plot.
답변 (2개)
Sean de Wolski
2012년 5월 18일
Like this:
figure;hold on
[xx yy] = meshgrid(1:10);
colormap([1 0 0;0 0 1]) %red and blue
surf(xx,yy,rand(10),ones(10)); %first color (red)
surf(xx,yy,rand(10)+10,ones(10)+1); %second color(blue)
view(17,22)
?
댓글 수: 0
Wagih Abu Rowin
2021년 2월 15일
You can specify the color for each surface individually like:
close all
figure;
%surf 1
surf(peaks+5,'FaceLighting','gouraud',...
'MeshStyle','column',...
'SpecularColorReflectance',0,...
'SpecularExponent',5,...
'SpecularStrength',0.2,...
'DiffuseStrength',1,...
'AmbientStrength',0.4,...
'AlignVertexCenters','on',...
'LineWidth',0.2,...
'FaceAlpha',0.2,...
'FaceColor',[0.07 0.6 1],...
'EdgeAlpha',0.2);
hold on
%surf 2
surf(peaks,'SpecularExponent',1,...
'SpecularStrength',1,...
'DiffuseStrength',1,...
'AmbientStrength',0.4,...
'FaceColor',[0.5 0.5 .5],...
'AlignVertexCenters','on',...
'LineWidth',0.2,...
'EdgeAlpha',1);
The results look like this:
댓글 수: 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!