Creating a 3d surface plot (2024)

7 views (last 30 days)

Show older comments

Reed on 25 Mar 2011

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/4006-creating-a-3d-surface-plot

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/4006-creating-a-3d-surface-plot

Answered: Shivam Anand on 11 May 2022

Accepted Answer: Matt Tearle

I have several x,y coordinates and an associated z-value for each x,y coordinate set. I would like to generate a 3d plot of these points, preferably with a mesh-like surface but am having trouble setting it up. I currently have three Nx1 vectors, one for the x-coordinates, one for the y-coordinates, and one for the z-values. How would I go about setting this plot up? The x,y coordinates are not in a nice rectangular grid, so meshgrid hasn't worked for me so far. Thanks, Reed

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

Accepted Answer

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/4006-creating-a-3d-surface-plot#answer_5725

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/4006-creating-a-3d-surface-plot#answer_5725

Open in MATLAB Online

TriScatteredInterp Here's an example (taken from the doc):

% Make some fake vector data

x = rand(100,1)*4-2;

y = rand(100,1)*4-2;

z = x.*exp(-x.^2-y.^2);

% Put data onto a grid

[qx,qy] = meshgrid(linspace(min(x),max(x)),linspace(min(y),max(y)));

F = TriScatteredInterp(x,y,z);

qz = F(qx,qy);

surf(qx,qy,qz)

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

More Answers (2)

the cyclist on 25 Mar 2011

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/4006-creating-a-3d-surface-plot#answer_5720

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/4006-creating-a-3d-surface-plot#answer_5720

You will probably be well served by some combination of the following commands:

  • griddata
  • meshgrid
  • plot3
  • triscatteredinterp
  • mesh
  • surf<li>
0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Shivam Anand on 11 May 2022

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/4006-creating-a-3d-surface-plot#answer_961705

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/4006-creating-a-3d-surface-plot#answer_961705

Open in MATLAB Online

x=[32 20 67 1 98 34 57 65 24 82 47 55 8 51 13 14 18 30 37 39 10 33 21 26 38 81 83 60 95 22 17 5 72 46 99 52 12 25 96 29 70 85 43 69 19 78 97 31 89 53 2 91 48 71 61 15 36 84 94 50 11 80 6 7 49 74 9 88 40 79 27 68 73 64 63 59 86 23 35 58 45 28 100 42 93 87 16 90 41 66 54 92 77 4 62 76 75 56 3 44];

y=[96 75 24 9 83 49 27 77 3 23 17 31 40 13 7 52 51 21 98 47 64 79 78 91 44 16 15 100 84 99 63 68 70 30 54 76 97 73 33 5 88 8 71 66 62 25 60 42 72 45 18 11 28 59 89 65 10 55 69 81 12 26 20 95 87 41 74 50 93 22 43 90 14 34 82 35 56 38 80 32 1 57 6 36 37 61 29 58 2 48 4 46 67 53 92 86 94 19 39 85];

z=[55 31 11 45 83 36 86 49 15 57 42 46 8 94 88 47 54 81 98 41 32 35 56 85 9 89 37 60 23 62 67 100 78 76 73 80 10 20 68 34 77 93 1 63 53 12 22 99 91 40 84 24 33 3 43 19 92 97 6 82 64 25 26 79 95 4 44 58 5 21 70 29 65 87 96 90 51 14 18 2 72 28 71 39 52 7 27 59 50 61 48 30 66 69 17 13 74 16 75 38];

xlin = linspace(min(x), max(x), 100);

ylin = linspace(min(y), max(y), 100);

[X,Y] = meshgrid(xlin, ylin);

% Z = griddata(x,y,z,X,Y,'natural');

% Z = griddata(x,y,z,X,Y,'cubic');

Z = griddata(x,y,z,X,Y,'v4');

mesh(X,Y,Z)

axis tight; hold on

plot3(x,y,z,'.','MarkerSize',15)

Creating a 3d surface plot (5)

Creating a 3d surface plot (6)

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABGraphics2-D and 3-D PlotsSurfaces, Volumes, and PolygonsSurface and Mesh Plots

Find more on Surface and Mesh Plots in Help Center and File Exchange

Tags

  • 3d
  • surface
  • plot

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


Creating a 3d surface plot (7)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

Creating a 3d surface plot (2024)

FAQs

How to plot a 3D surface? ›

3D Surface Plots in Python
  1. Topographical 3D Surface Plot.
  2. Passing x and y data to 3D Surface Plot. ...
  3. Surface Plot With Contours.
  4. Display and customize contour data for each axis using the contours attribute (reference).
  5. Configure Surface Contour Levels. ...
  6. Multiple 3D Surface Plots.
  7. Setting the Surface Color. ...
  8. Reference.

How do you plot a 3D surface in Excel? ›

Under the “INSERT” tab, we can see the “Chart” section. Choose “Stock,” “Surface,” or Radar Chart in excel in this section. Under this category of charts, choose the “3-D Surface” chart. As soon as you click on the “3-D Surface” chart, you will see the below default surface chart in your worksheet.

How to draw a 3D surface plot in Python? ›

We could plot 3D surfaces in Python too, the function to plot the 3D surfaces is plot_surface(X,Y,Z), where X and Y are the output arrays from meshgrid, and Z=f(X,Y) or Z(i,j)=f(X(i,j),Y(i,j)). The most common surface plotting functions are surf and contour.

What is the formula for 3D surfaces? ›

The graph of a 3-variable equation which can be written in the form F(x,y,z) = 0 or sometimes z = f(x,y) (if you can solve for z) is a surface in 3D.

How to create a 3D chart in Excel? ›

Step-by-Step: 3D Excel Chart

On the Insert tab, choose the Column dropdown in the Charts You can now choose a 3D chart type for your Summary data. This example shows the 3D Column chart type, but there are many 3D Excel charts to choose from. Choose the best for your data and audience!

What is 3D surface chart? ›

A Surface chart (or 3D Surface plot) is a chart type used for finding the optimum combinations between two sets of data. As in a topographic map, the colors and patterns indicate the areas that are in the same range of values.

How to create a 3D model in Excel? ›

On the Insert tab of the ribbon select 3D Models and then From a File. Use the 3D control to rotate or tilt your 3D model in any direction. Just click, hold and drag with your mouse. Drag the image handles in or out to make your image larger or smaller.

Can Excel do 3D scatter plots? ›

The 3D scatter plot chart in Excel is mainly used to show the relationship between two sets of data related to each other. The scattered chart has X and Y variables. This chart helps show related data like rainfall vs. umbrellas sold, rainfall vs.

What is the formula for a 3D graph? ›

A graph in 3 dimensions is written in general: z = f(x, y). That is, the z-value is found by substituting in both an x-value and a y-value. The first example we see below is the graph of z = sin(x) + sin(y).

How to plot a 3D surface plot? ›

Create Chart

Next, fill out the necessary 'X', 'Y' and 'Z' values from their respective dropdown menus. This will create a 3D surface, as seen below. In this example, our data was formatted as a Z matrix so we will add all columns of our dataset to the 'Z' dropdown.

How to plot a 3D surface in Excel? ›

Go to the "Insert" tab in the Excel ribbon and select the desired chart type under the "Charts" section. Choose the 3D plot option that best fits your needs. Customize your chart by adding titles and labels and adjusting the appearance of the plot. Analyze your chart to identify trends and patterns in your data.

When to use a 3D surface plot? ›

Use 3D Surface Plot to examine the relationship between a response variable (Z) and two predictor variables (X and Y), by viewing a three-dimensional surface of the predicted response. You can choose to represent the predicted response as a smooth surface or a wireframe.

How to do 3-D surface area? ›

To calculate surface area, we add the areas of all the faces of the three-dimensional figure.

What is a 3-D surface contour plot? ›

Contour plots display the 3-dimensional relationship in two dimensions, with x- and y-factors (predictors) plotted on the x- and y-scales and response values represented by contours. A contour plot is like a topographical map in which x-, y-, and z-values are plotted instead of longitude, latitude, and elevation.

Top Articles
Latest Posts
Article information

Author: Duncan Muller

Last Updated:

Views: 6168

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Duncan Muller

Birthday: 1997-01-13

Address: Apt. 505 914 Phillip Crossroad, O'Konborough, NV 62411

Phone: +8555305800947

Job: Construction Agent

Hobby: Shopping, Table tennis, Snowboarding, Rafting, Motor sports, Homebrewing, Taxidermy

Introduction: My name is Duncan Muller, I am a enchanting, good, gentle, modern, tasty, nice, elegant person who loves writing and wants to share my knowledge and understanding with you.