How to generate triangular heatmap using matlab?
37 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/282323/image.jpeg)
Any idea to generate using matlab?
The data I have is a table shown below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/282324/image.jpeg)
How can I make the heatmap directly from above table without the need to make a matrix?
0 comentarios
Respuestas (2)
KALYAN ACHARJYA
el 6 de Abr. de 2020
Editada: KALYAN ACHARJYA
el 6 de Abr. de 2020
data=tril(randi(100,[15,15]));
imagesc(data);
colormap summer
colorbar
Plese DO modification and addition(labels) as per required
0 comentarios
Frederick Vonberg
el 19 de Jun. de 2020
Editada: Frederick Vonberg
el 20 de Jun. de 2020
One other alternative, if you want to retain some of the functionality associated with heatmap, is to replace replace all values above the diagonal with NaN and then set all NaNs to white. The result will (look like) a triangular heatmap.
data = randi(100, [15, 15]);
ii = ones(size(data));
idx = tril(ii);
data(~idx) = nan;
heatmap(data, 'MissingDataColor', 'w', 'GridVisible', 'off', 'MissingDataLabel', " ")
Granted you now have an issue with an empty "missing data" label on the colorbar. You may find it preferable to set 'ColorbarVisible' to 'off', but now you have the options provided by the heatmap function.
0 comentarios
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!