Plot multiple surfaces on same plot with different color for each surface

218 ビュー (過去 30 日間)
Juan B. Gutierrez
Juan B. Gutierrez 2012 年 5 月 18 日
回答済み: Wagih Abu Rowin 2021 年 2 月 15 日
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
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
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)
?

Wagih Abu Rowin
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:

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by