Effacer les filtres
Effacer les filtres

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

15 vues (au cours des 30 derniers jours)
Samantha Clayton
Samantha Clayton le 7 Juin 2018
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])

Réponse acceptée

Walter Roberson
Walter Roberson le 8 Juin 2018
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.

Plus de réponses (0)

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by