Filter löschen
Filter löschen

How to draw a heatmap with two numerical variables?

18 Ansichten (letzte 30 Tage)
Yuhong Jin
Yuhong Jin am 27 Nov. 2019
Beantwortet: Hritika Suneja am 29 Dez. 2020
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.

Antworten (1)

Hritika Suneja
Hritika Suneja am 29 Dez. 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

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by