Plot multiple surfaces on same plot with different color for each surface
218 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Anant Gairola
le 13 Nov 2016
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.
Réponses (2)
Sean de Wolski
le 18 Mai 2012
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 commentaires
Wagih Abu Rowin
le 15 Fév 2021
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 commentaires
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!