How to draw a heatmap with two numerical variables?

조회 수: 18 (최근 30일)
Yuhong Jin
Yuhong Jin 2019년 11월 27일
답변: Hritika Suneja 2020년 12월 29일
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.

답변 (1개)

Hritika Suneja
Hritika Suneja 2020년 12월 29일
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

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by