フィルターのクリア

How can I move a colorbar when using heat maps? (2017a)

6 ビュー (過去 30 日間)
Samantha Clayton
Samantha Clayton 2018 年 6 月 7 日
回答済み: Walter Roberson 2018 年 6 月 8 日
How can I move a colorbar when using heat maps? (2017a) I keep getting the error:
Error using matlab.graphics.chart.Chart/colorbar Output arguments are not supported when using colorbar with heatmap.
Using 2017a
subplot('Position',[0.16 0.065 0.762 0.11])
heatmap(p_index, s_num, inc_diff(s_num,:), 'ColorLimits', [real_min, real_max], 'GridVisible', 'off', 'CellLabelColor', 'none');
xlabel('Parameter')
set(colorbar,'Position',[0.9 0.1 0.07 0.8])

採用された回答

Walter Roberson
Walter Roberson 2018 年 6 月 8 日
That does not appear to be possible.
heatmap() turns out to create a sort of axis object, and colorbar notices that its parent is a heatmap and refuses to do some things.
If you do
ax = gca; %then ax becomes the handle to the heatmap
axs = struct(ax); %and ignore the warning
cb = axs.Colorbar; %now you have a handle to the colorbar object
However, if you try to set cb.Position then that will fail: the colorbar is being controlled by a layout manager which will promptly get confused and error out.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by