Question

I have a 10018x3 matrix, where each row represents a measurement at a particular (x, y) coordinate. That is, the 1st column contains all the x values, the 2nd has all the y values, and the 3rd contains all the measurements.

The matrix is available here.

I now wish to plot the heat map of the measurements. How should I do that?


My attempt, although maybe stupid, is to do scatter3(x, y, z), which renders me this enter image description here

Although I can see the trend, yet what I am wishing for is this. enter image description here

Was it helpful?

Solution

You can also interpolate using TriScatteredInterp and create a contour plot:

x=linspace(min(data(:,1)),max(data(:,1)),150);
y=linspace(min(data(:,2)),max(data(:,2)),150);
[X,Y]=meshgrid(x,y);
F=TriScatteredInterp(data(:,1),data(:,2),data(:,3)-1);
contourf(X,Y,F(X,Y),100,'LineColor','none')

OTHER TIPS

I used scatter3 like you did, but you can specify the size of each point as well as the colours for each marker that belong to the colour map. Once I did that, I set the view so that I'm looking straight above.

Try this code. This is assuming that your data is stored in a matrix called data and in that structure that you just talked about earlier:

% Set colour map
colormap(jet);
% Make 3D plot with filled circles coloured in the scheme of the 
% measurements
scatter3(data(:,1), data(:,2), data(:,3), 30, data(:,3), 'filled');
% Set the azimuth and latitude to look directly above
view(0,90);
colorbar; % Throw in the colour bar.

This is what I get:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top