How to draw a heatmap with two numerical variables?
18 ビュー (過去 30 日間)
古いコメントを表示
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.
How should I write my Matlab script?
Thanks in advance.
0 件のコメント
回答 (1 件)
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!