How do I extract data point from a cell inside a heatmap?

8 visualizaciones (últimos 30 días)
Yiling
Yiling el 24 de En. de 2025
Respondida: Cris LaPierre el 24 de En. de 2025
I created a heatmap using the "heatmap" function by feeding a 2-dim matrix. I see I can click into each heatmap cell and show the x name, y name and the value. I am just wondering how I can click into the cell and extract these information (e.g. store them into a variable and use them for other calculations?)

Respuestas (1)

Cris LaPierre
Cris LaPierre el 24 de En. de 2025
I'm sure there's a way to develop something that does this graphically, but I would use groupsummary to create the heatmap results.
load patients
tbl = table(LastName,Age,Gender,SelfAssessedHealthStatus,...
Smoker,Weight,Location);
heatmap(tbl,'Smoker','SelfAssessedHealthStatus')
heatTbl = groupsummary(tbl,{'Smoker','SelfAssessedHealthStatus'})
heatTbl = 8x3 table
Smoker SelfAssessedHealthStatus GroupCount ______ ________________________ __________ false {'Excellent'} 24 false {'Fair' } 10 false {'Good' } 24 false {'Poor' } 8 true {'Excellent'} 10 true {'Fair' } 5 true {'Good' } 16 true {'Poor' } 3

Categorías

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

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by