How to draw a heatmap with two numerical variables?

17 ビュー (過去 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 Center および File ExchangeData Distribution Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by