Notna
Notna

Reputation: 525

Display the colorbar in heatmap MATLAB

I'm creating the following heatmap:

h = HeatMap(CorrelationsMV, 'RowLabels', labels, 'ColumnLabels', labels, 'Colormap', map);
colorbar;
caxis([-1, 1]);

And for some reason, the colorbar is displayed in a second, empty heatmap :enter image description here enter image description here

While what I need is simply that: (that I can do manually through the GUI, but I need it to be automated) enter image description here

Upvotes: 0

Views: 1878

Answers (2)

makarand kulkarni
makarand kulkarni

Reputation: 301

Instead using colorbar the colorbar_levels will help if using older versions of matlab. The use is simple. you can google it

[h_bar]=colorbar_levels(Levls,varargin)

Upvotes: 0

Adiel
Adiel

Reputation: 3071

The HeatMap graphics object does not support colorbar method. You can render it to a regular axes with the method plot, then use colorbar as usual:

h = HeatMap(CorrelationsMV, 'RowLabels', labels, 'ColumnLabels', labels, 'Colormap', map);

then:

plot(h);
colorbar;

or:

ax=h.plot;
colorbar(ax);

Upvotes: 1

Related Questions