Use distinct colormaps for two different surf plots on the same figure

52 ビュー (過去 30 日間)
Leo Simon
Leo Simon 2017 年 11 月 11 日
コメント済み: Leo Simon 2017 年 11 月 11 日
Using R2016b, I would like to create two surf plots and use a different colormap for each one. It appears that the only way to assign a color map is to apply it to the axis handle. In the code below I was hoping that AxOne and AxTwo would be different objects, but alas, they appear to be the same thing. Hence when I change the colormap for AxTwo, it changes the colormap for both plots. Is there a way to set the colormap for the first surf to be 'cool' and for the second one to be 'hot'?
hold on;
[x,y,z] = peaks;
h1 = surf(x,y,z)
view(3)
AxOne = get(h1,'Parent');
colormap(AxOne,'cool');
h2 = surf(y,x,3+z)
AxTwo = get(h2,'Parent');
colormap(AxTwo,'hot');

採用された回答

Walter Roberson
Walter Roberson 2017 年 11 月 11 日
No, only container objects can hold colormaps, not individual graphics objects. User-created hggroup cannot hold them either.
You have two choices:
  1. use two axes, probably set to the same position, such as you might for plotyy or the newer yyaxis; or
  2. draw the first item with appropriate colormap, then use a tool such as the File Exchange freezeColors() to convert the item to RGB; once it is RGB, you can put up the second item and change colormaps, as the first item will no longer be using a colormap.
  1 件のコメント
Leo Simon
Leo Simon 2017 年 11 月 11 日
FreezeColors is simple and works great! Thanks very much.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrange についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by