MATLAB Answers

Overlap two pcolor with different color and set up transparency

42 views (last 30 days)
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,...
% Red layer:
hold on
p2 = surf(X,Y,zeros(size(Z2)),'AlphaData',Z2,...
grid off

  1 Comment

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