How to generate a heat map using imported data with (x,y, z as color)

조회 수: 15 (최근 30일)
Prosopo
Prosopo 2019년 11월 16일
댓글: Jyothis Gireesh 2019년 11월 22일
I have imported a very large data file into MATLAB. I am curious how I can generate a heat map of the values using z as color so that the higher z values are more intense in color?
I have labled the imported file 'A' which is a 5798000x3 table. I have had success plotting the table using:
x = A{:,1};
y = A{:,2};
z = A{:,3};
figure(1)
plot3(Ax,Ay,Az)
grid on
however I would like to generate a heat map of the data.
Thanks in advance!

답변 (1개)

Jyothis Gireesh
Jyothis Gireesh 2019년 11월 19일
You may use the following syntax to create the heat map.
h = heatmap(tbl,xvar,yvar,'ColorVariable',cvar)
where
  • tbl is the table name A
  • xvar indicates the variable name of the column to be displayed along the x-axis
  • yvar indicates the variable name of the column to be displayed along the y-axis
  • Specify cvar to control the heat map values according to the variable values. In this case, cvar corresponds to the 3rd column name.
Also, please refer to the following documentation link about creating heatmaps and customizing them
  댓글 수: 2
Prosopo
Prosopo 2019년 11월 21일
I have incorporated the above mentioned syntax, however I have run across the error:
Warning: Error updating HeatmapChart.
Values in the source table variable 'Ay' are not grouped into discrete categories. Use the discretize function to group your values.
I am using the following:
Ax = A{:,1};
Ay = A{:,2};
Az = A{:,3};
A = table(Ax,Ay,Az);
h = heatmap(A,'Ax','Ay','ColorVariable','Az');
I am assuming values must be discretized in order plot them into a heatmap, however I am unsure how to discretize Ax,Ay, and Az properly to produce an accurate heatmap of my imported data.
Jyothis Gireesh
Jyothis Gireesh 2019년 11월 22일
Can you attach the table data so that I can take a look at it?

댓글을 달려면 로그인하십시오.

카테고리

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