How to create a good looking surface plot with inconsistent mesh size?
15 views (last 30 days)
Show older comments
I have data that forms a 3-dimensional surface that was gathered with an inconsistent mesh size. NOTE: I've now edited this post so that the data file is attached and the image files showing my attempt at plots are shown below.
An inconsistent mesh size was used in order to examine fine details. I would like to create a nice looking surface plot (maybe using interpolation?) to include in a publication. You can locate my data file here: https://pastebin.com/tKTzLSkL. EDIT: The data file is now attached to this post. I've posted some images below, with descriptions of what I've tried, so that folks have a better idea of what I'm talking about and struggling with. Here's an image of what a scatter plot of my data looks like:

I'm pretty inexperienced with matlab and don't know what I'm doing. I've been able to create a plot in which a triangular mesh connects all of my data points, but the color scheme looks pretty ugly. It's certainly not something I'd put on a slide for a presentation, let alone in a publication.
Here's my attempt at a triangular mesh in matlab:

Here's the code I tried using to generate the triangular mesh plot (note: I stored my data in a matrix called 'largecomp'):
x=largecomp(:,1);
y=largecomp(:,2);
gridDelaunay=delaunay(x,y);
trisurf(gridDelaunay,x,y,z,'EdgeColor','none')
6 Comments
KSSV
on 28 Jun 2017
data = load('data.txt') ;
x = data(:,1) ; y = data(:,2) ; z = data(:,3) ;
tri = delaunay(x,y);
trisurf(tri,x,y,z) ;
Are you sure that your data is correct?
Answers (1)
Benjamin Becker
on 28 Jun 2017
Edited: Benjamin Becker
on 28 Jun 2017
You could also have a look at the MATLAB function scatteredInterpolant. It does linear interpolation over a non-regular grid.
[x,y,z] = textread('data.txt','%f %f %f');
F = scatteredInterpolant(x,y,z,'linear','nearest');
x = linspace(min(x),max(x),200);
y = linspace(min(y),max(y),200);
[X,Y] = meshgrid(x,y);
Z = F(X,Y);
figure
mesh(X,Y,Z)
The figure then looks like this:

If you want to change the color take a look at the MATLAB function
colormap
As a first step it might be good to clean the data.
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!