MATLAB Answers

Overlap two pcolor with different color and set up transparency

42 views (last 30 days)
Xin
Xin on 22 Feb 2017
Commented: Xin on 23 Feb 2017
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

  1 Comment

Shaibal Ahmed
Shaibal Ahmed on 22 Feb 2017
I have a similar question, would be great if someone could answer it.

Sign in to comment.

Accepted Answer

Chad Greene
Chad Greene on 23 Feb 2017
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

  1 Comment

Xin
Xin on 23 Feb 2017
Thanks for your reply! Another issue is that the two figure has different colormap, how would you deal with it? Is it possible to put two different colormap together in one figure?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by