Overlay imagesc and contour in subplot with different colour bars

7 ビュー (過去 30 日間)
Hugo Fortescue
Hugo Fortescue 2021 年 3 月 17 日
編集済み: Adam Danz 2021 年 3 月 22 日
Hi All,
I have an image i would like to produce as part of an array of 6, and I have the following code:
Unwrap = subplot(2,3,5);
hold on
imagesc(G_Unwrapped); title('Phase Change');colorbar, axis square
colormap(Unwrap,'gray')
contour(G_Unwrapped, 'ShowText','on');
hold off
However, as the axis handle applies to the whole subplot, and not the indervidual plot commands I can't think of a way to apply a second colour map too the contour plot.
Many thanks in advanced for any help!

採用された回答

Adam Danz
Adam Danz 2021 年 3 月 17 日
編集済み: Adam Danz 2021 年 3 月 17 日
> the axis handle applies to the whole subplot, and not the indervidual plot commands
That's correct. A workaround is to assign two overlapping axes with care so that the axes are linked.
Follow this demo that carefully overlays imagesc and contour
You can easily add two independent colobars to the example above following this similar example,
Give it a shot and if you get stuck, show us what you've got and I can nudge you in the right direction.
  2 件のコメント
Hugo Fortescue
Hugo Fortescue 2021 年 3 月 18 日
Hi there,
Thanks for those links. I have manged to follow them to get a single figure with 2 colourscales, but I'm not sure how to make it work for a subplot instead.
Wrap = subplot(2,3,5);
ax1 = axes(Wrap);
ax2 = copyobj(ax1,Wrap);
This spits out a "Too many output arguments" error message
Adam Danz
Adam Danz 2021 年 3 月 18 日
編集済み: Adam Danz 2021 年 3 月 22 日
This line doesn't make sense. Wrap is the axis handle.
ax1 = axes(Wrap);
The first 3 lines in the first link in my answer should look like this for subplots,
fig = clf();
ax1 = subplot(___);
ax2 = copyobj(ax1,fig);
% then continue with the demo in the link
I tested that full solution using subplots in r2021a and it works well.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by