Effacer les filtres
Effacer les filtres

How to draw a heatmap with two numerical variables?

18 vues (au cours des 30 derniers jours)
Yuhong Jin
Yuhong Jin le 27 Nov 2019
I was trying to plot a heatmap with two variables, each of which is in a defined range:
And I want to only represent the relationship between a2-a1 and abs(b1b2) in the determinant in the plot.
Screen Shot 2019-11-27 at 17.14.51.png
How should I write my Matlab script?
Thanks in advance.

Réponses (1)

Hritika Suneja
Hritika Suneja le 29 Déc 2020
You can create a table for Xvar, Yvar and Cvar. Here Xvar is the data that will ppear along the x axis. Yvar is the data that will appear along the Y axis and Cvar is used to calculate th color of the data . The default colors are based on a count aggregation, which totals the number of times each pair of x and y values appears together in the table. Once the table is created (let's say tb1) you can create a heatmap using the below command.
>> heatmap(tbl,Xvar,Yvar,'ColorVariable',Cvar)
You can also use the below command :
>> heatmap(xvalues,yvalues,cdata)
Here xdata and ydata are the values appearing along the x-axis and y-axis respectively, specified as a categorical array, string array, numeric array, or cell array of character vectors, and cdata is the matrix specifying color data.
Refer to the following link for more details : https://www.mathworks.com/help/matlab/ref/heatmap.html#bvh0gj7-1-cdata

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by