Plotting a heat map with two variables with color dependent on third variable
Ältere Kommentare anzeigen
I have a matrix of x and y values, and I would like to plot them using a heat map. However, there is also a third column in the matrix of z-values, which I would like to determine the color of each point in the heat map. How would I do this?
3 Kommentare
Jess Lovering
am 2 Okt. 2019
You should start by looking into the help for the pcolor plot. Is this the graphic that you are trying to achieve?
Chinwe Orie
am 3 Okt. 2019
Chinwe Orie
am 3 Okt. 2019
Antworten (1)
Poonam Mahapatra
am 13 Apr. 2020
0 Stimmen
You can make a table of Xdata, Ydata and Cdata where Xdata is the variable having data to be displayed along the x-axis, Ydata is the variable having data to be displayed along the y-axis and Cdata is the variable having values to determine the color of each cell, using the following command:
>> tb1 = table(Xdata, Ydata, Cdata);
Then you can plot the heatmap using the following command:
>> h = heatmap(tb1,'Xdata','Ydata','ColorVariable','Cdata');
Please refer to the following documentation for more details:
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!