How can I move a colorbar down in a subplot?

27 ビュー (過去 30 日間)
Daniel King
Daniel King 2021 年 3 月 22 日
コメント済み: Daniel King 2021 年 3 月 24 日
I've been having trouble fitting a colorbar to describe the scheme I'm using for these subplots. After finally getting a custom colorbar, I can't figure out how to move it downwards so it occupies the space to the right of plot N. Can anyone offer a suggestion?
Thank you.

採用された回答

Adam Danz
Adam Danz 2021 年 3 月 23 日
編集済み: Adam Danz 2021 年 3 月 24 日
After adding the colorbar, change its position property. You can use the positions of the other axes to align the colorbar as needed.
Here's a demo (works with subplot or tiledlayout).
Also see this answer.
figure()
ax = gobjects(1,4);
ax(1) = subplot(2,2,1); title('Axis 1')
ax(2) = subplot(2,2,2); title('Axis 2')
ax(3) = subplot(2,2,3); title('Axis 3')
% add colorbar to axis 2
cb = colorbar(ax(2),'orientation','horizontal','Location','SouthOutside');
% Reposition the colorbar using the y-position of axis 3.
cb.Position(2) = ax(3).Position(2); % ax(3) is on the bottom row
  1 件のコメント
Daniel King
Daniel King 2021 年 3 月 24 日

Thank you that worked great

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

その他の回答 (1 件)

Katharina
Katharina 2021 年 3 月 22 日
Open property inspector, click and move the bar where you want it to be.
Either check the values for ColorBar position in the Property Inspector and include the manual position in your code, or go to File-> Generate Code... and see how MATLAB automatically incorporated this change.

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by