Map Axes and Colorbars - Colorbar Overlapping Labels

3 ビュー (過去 30 日間)
millercommamatt
millercommamatt 2022 年 12 月 13 日
回答済み: Divyanshu 2023 年 9 月 1 日
When creating a colorbar to go with a map axes based plot, the colorbar overlaps the labels.
What's the optimal solution for preventing this?
Manually defining the position is hard to figure for a general case and doesn't tolerating window resizing without some sort of callback function being developed.
The root of the problem seems to be rooted in the fact that the map axis objects don't respect the bounds of the parent invisible axis that the colorbar is positioned in reference to.
Simple example. Give the resulting a figure a resize and note how the colorbar overlaps the map axes labels.
fig_h = figure();
maxis_h = worldmap([20 40],[-90 -60]);
colorbar

回答 (1 件)

Divyanshu
Divyanshu 2023 年 9 月 1 日
I understand that plotting both map-axes and colorbar result in the colorbar overlapping with the map-axes. Here is a workaround which enables to manually set the position of colorbar:
fig_h = figure();
maxis_h = worldmap([20 40],[-90 -60]);
x = maxis_h.Position(1);
y = maxis_h.Position(2);
cb = colorbar;
a = cb.Position;
set(cb,'Position',[x+0.79 a(2) a(3) a(4)])
You can go through the following documentation for further details about ‘set’ function of MATLAB:

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by