File Exchange

image thumbnail

Making Surface Plots From Scatter Data

version (92 KB) by Zain Mecklai
How to turn a collection of XYZ triplets into a surface plot.


Updated 01 Sep 2016

View Version History

View License

Editor's Note: This file was a File Exchange Pick of the Week

How do you turn a collection of XYZ triplets into a surface plot? This is the most frequently asked 3D plotting question that I got when I was in Tech Support. This submission explains how.

Cite As

Zain Mecklai (2021). Making Surface Plots From Scatter Data (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (85)

Salvador Montalvo

Zhen Kok

Colin Burn

Phivos Koumides

Excellent work!!! I've spent days trying to do this.


Thank you very much. Hope can combine such figures with CST.

Pedro Rubio Gallardo


Karoline Neumann

Only works well if the layered Z planes do not have very close x,y corrodinates. Mine have, the results make triangles that connects to z far away, just because it is close in xy.

dorian drevon

not possible to smooth it ?

Nils Ole Stabo-Eeg

Scott Gillette

Lido Ju

Mengsi Gao

Zachary Berent

Kaela McGuire

Rajib Mukherjee

Pier Carlo Cadoppi

Perfect! This should be part of the software!

Jerry Nweisser

no help

David Newton

Excellent post. Is there a similar function, or set of steps to calculate gradients on scatter data from X, Y, Z triplets?

behnam javadi

Pi Ting

thanks a lot

Min-Ye Zhang


thank you very much!!

Frank Riley

Steve Hageman

Thanks for the tip, works perfectly.

Laura Paez

Swathi Chandrasekar


Toby Hill-Smith

Lifesaver, cheers. For me it really helped getting rid of the "clean it up" section at the bottom



It does not work for a sphere.

changseop kwon

Awesome!!! Thanks!

Iddo Weiner


Beth Wilcox




Liye SUN

Works Well!

Kourosh Behzadian

Very helpful!

Sarah Olson

So helpful!

Mario Contreras

E. Cheynet

Ali Ghayoor


Jang DV

Excellent !

Yaniv Netboute

Roman Jamy

Asa Darnell

A+. I'm using this to visualize data from a Photogrammetry software that outputs 'random' data points instead of points on a standard grid and it works perfectly! Thanks!!!!!!!!


Great function, helped a lot for creating lookuptables.

Amanda Childers

This is exactly what I've been looking for for years. Worked great.


Rick van Rijn



very helpful thanks a lot

Highman Field

But this doesn't work when a surface is curved like a ball. You triangulate these projections of the vertices on x-y plane, but some obtained triangles are not the projections of the real triangles on the surface.



just what i needed!!!!

Seyed Valashani

thanks, solved my problem as well

Manel Soria

Thanks !


Excellent. Well done!

IIT Bombay

extremely useful


Saurabh Singh

Awesome!! Can anybody tell if I can draw contour plot on the same?

Nunthadech Rodcheuy


C. Maguire

Using "delaunay" is what "griddata" does. It's only okay for 2D data, but very slow for 3D data (z will be an individual dimension, instead of a value of f(x,y) in 3D data situation). Because of this reason, "griddata3" is good but too slow.

Carlos Adrian Vargas Aguilera

This is nice Zain. Why don't you made a function? Ignoring NaNs also.

Thomas Jansson

Just what I was looking for - this should have a seperate function in Matlab or at least be listed in the help files. :)

Laura .

Works great!

Johnny Green

Thanks so much!

Catherine St-P

Thank you!!! It saved me sooo much time! Wow...

jack zuo

good stuff!

Jen Badham

Just what I needed

Xiaolan Wang

Genius idea. Easy and works just perfectly. Thank you very much.

Blake Fleischer

Being new to this program, the tutorial was essential for me. Only problem I had was typing the right commands. Many Thanks!

Oya Mercan



Nimal L


quite good!

Chris Lim

Any idea on how to make a contour plot with scatter data?

sheela kumar

cool !

Chammika Udalagama

Goncalo Gil

Sweet!!! That did it!

remove [NOSPAM!!!] from email if you would like to contact me.

Eric Benson

Solved my problem!

Robert Riley

Lorenzo Natale

Stefan Burger

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!