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

14 visualizaciones (últimos 30 días)
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])

Respuesta aceptada

Walter Roberson
Walter Roberson el 8 de Jun. de 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.

Más respuestas (0)

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by