Overlap two pcolor with different color and set up transparency

38 次查看(过去 30 天)
I have two figures like below.
What I want to do is 1) overlap them into one figure. 2) set transparency at the place where they meet each other. The colour can be changed, can be any color where an overlap will look nice.
Many thanks

采纳的回答

Chad Greene
Chad Greene 2017-2-23
What about this?
% Some sample data:
[X,Y,Z1] = peaks;
Z2 = flipud(Z1);
% Blue layer:
p1 = surf(X,Y,zeros(size(Z1)),'AlphaData',Z1,...
'FaceAlpha','interp',...
'FaceColor','blue',...
'edgecolor','none');
% Red layer:
hold on
p2 = surf(X,Y,zeros(size(Z2)),'AlphaData',Z2,...
'FaceAlpha','interp',...
'FaceColor','red',...
'edgecolor','none');
view(2)
grid off
  3 个评论
Alexander Audet
Alexander Audet 2022-9-7
Yes, just figured this out. You need to put them on separate axes, then turn off the second axis visibility:
% Some sample data:
[X,Y,Z1] = peaks;
Z2 = flipud(Z1);
figure
%Create the first axis and colormap
ax1 = axes;
hold on
colormap(ax1, hot)
% Plot on first axis
h1 = surf(ax1,X,Y,zeros(size(Z1)),Z1,'edgecolor','none')
%Create the second axis and colormap
ax2 = axes;
hold on
colormap(ax2, winter)
% Plot on second axis
h2 = surf(ax2,X,Y,zeros(size(Z2)),Z2,'edgecolor','none', 'FaceAlpha', 0.5)
% Turn 3D surface into 2D surface (map view)
view(2)
grid off
%Turn off ax2 so you can see the first plot
ax2.Visible = 'off';
ax2.XTick = [];
ax2.YTick = [];
Walter Roberson
Walter Roberson 2022-9-7
Historically there could only be one colormap for each figure, but that was changed eventually to permit one colormap per axes.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Orange 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by