필터 지우기
필터 지우기

How to add a colorbar in a heatmap?

조회 수: 5 (최근 30일)
Julia Moore
Julia Moore 2020년 6월 2일
편집: Ayden Clay 2020년 6월 2일
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

채택된 답변

Ayden Clay
Ayden Clay 2020년 6월 2일
편집: Ayden Clay 2020년 6월 2일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by