Borrar filtros
Borrar filtros

How to add a colorbar in a heatmap?

5 visualizaciones (últimos 30 días)
Julia Moore
Julia Moore el 2 de Jun. de 2020
Editada: Ayden Clay el 2 de Jun. de 2020
Hey guys!
I am trying to do a heatmap, using a the heatmap function. But I am not being capable of adding a colorbar. Does anyone know if it is possible using the MATLAB version 2016a?
Also my current heatmap is like this, I would like to invert the beggining of the rows position. Is it possible that the row number 1 start on the first line not in the last one? And how could I eliminate the elements above the main diagonal?
Thnkss

Respuesta aceptada

Ayden Clay
Ayden Clay el 2 de Jun. de 2020
Editada: Ayden Clay el 2 de Jun. de 2020
Hi Julia!
In 2006a MATLAB introduced the colorbar command that automatically adds a colorbar and it can be included underneath any plot function and it will automatically generate a colorbar. For more options type
doc colorbar
into the matlab command window.
As for the second half of your question, you can control the axis direction using
set(gca,'YDir','reverse');
which ought to solve your issue. As for eliminating the values above the diagonal you would have to mess with the data that you are using to generate the heatmap. Since this is in a table (for use with the heatmap command).
Suppose your table is called T, then you may be able to use the following:
for i = 1:size(T,1)-1
T{i,i+1:end} = [];
end
Though I admit my knowledge of tables is severely limited.

Más respuestas (0)

Categorías

Más información sobre Colormaps 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