Filled contour/colorized 2-D surface plot with large 3-D array (10000 x 3)

Hi!
Can you please help me generate a filled contour plot and/or a colorized 2-D surface plot using a large 3-D array (10000 x 3; see attached file)? The data is arranged in the following format: x-coordinate, y-coordinate and density.
I am hoping to visually end up with something like this (i.e., with minimal interpolation):
Thanks so much!

 Réponse acceptée

Thanks for your help Mathieu! I managed to solve this problem using imshow by looking at previous Matlab answers by Image Analyst:
x = D(:,1);
Unrecognized function or variable 'D'.
y = D(:,2);
z = D(:,3);
xgrid = reshape(x,[100,100]);
ygrid = reshape(y,[100,100]);
zgrid = reshape(z,[100,100]);
C= [xgrid ygrid zgrid];
C2 = imresize(zgrid, 100); % Blow up by a factor of 100;
figure;
imshow(C2,'XData', x./1e3, 'YData', y./1e3);
axis on;
clim([0e14 0.16e14])
cmap = jet(256);
colormap(cmap);
h = colorbar;
h.Label.String = 'Number Density';
h.Location = 'northoutside';
xlabel('Km'); ylabel('Km');
set(gca,'Fontsize',16);
ax = gca; % get the current axis
ax.Clipping = 'off'; % turn clipping off

Plus de réponses (1)

hello
maybe this ?
your data is large but lacks some refinement in the central area of the peak
90% of your data is Z close to zero
3D rendering
if we make a flat 2D rendering you will see that we have a very coarse grid in the center area
zoomed here :
load('test_data.mat')
x = D(:,1);
y = D(:,2);
z = D(:,3);
%% Plot it with TRISURF
tri = delaunay(x,y);
h = trisurf(tri, x, y, z);
set(h,'LineWidth',0.01)
shading interp
% view(2); % uncomment to have a flat 2D rendering
colorbar EastOutside

2 commentaires

Thank you so much! However, the grid is actually uniform (not coarse in the center), as can be seen by plotting scatter(x,y). I've tried using your solution, pcolor and imagesc, but all of them seem to show 'wedge'-like shapes near the origin.
Do you know how to ensure that the interpolation is done smoothly?
sorry if I was unclear
I didn't mean that the resolution was coarser in the center, I just mean that the overall resolution is too coarse to give a smooth rendering of what is supposed to be displayed
also , we could reduce the number of points as outside the very center portion, the rest is almost zero in z direction, so not very interesting
yes , if you display the data with scatter, you can see that the number of points where the z data is non zero is very limited
you may try to improve with interp2 but don't do it on the full data set , simply on the center area
how were the data actually generated ?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Performance dans Centre d'aide et File Exchange

Produits

Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by