Matlab 3d scatter plot | Learn the Examples of Matlab 3d scatter plot (2024)

Updated March 13, 2023

Matlab 3d scatter plot | Learn the Examples of Matlab 3d scatter plot (1)

Introduction to Matlab 3d scatter plot

3 D scatter plots are used to show the relationship between 3 variables on the cartesian coordinates. 3 D scatter plots are used to interpret the spread of data and identify any outliers. Scatter plots are very useful in data science, where relationships in the test data are used to create algorithms to predict the output. In MATLAB, we use the scatter3() function with 3 arguments to create 3D plots. In this topic, we are going to learn about Matlab 3d scatter plot.

ADVERTIsem*nT Popular Course in this categoryMATLAB - Specialization | 5 Course Series | 3 Mock Tests

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Syntax of the scatter3 function:

  1. scatter3 (a, b, c)
  2. scatter3 (a, b, c, Z)
  3. scatter3 (a, b, c, Z, Y)

Description of the scatter3 function:

  1. scatter3 (a, b, c) is used to create a scatter plot for the input vectors a, b, c. By default, MATLAB scatter plots the data points as circles
  2. scatter3 (a, b, c, Z) is used to create a scatter plot for the input vectors a, b, c with the circles of the size defined by the argument ‘Z.’
  3. scatter3 (a, b, c, Z, Y) is used to create a scatter plot for the input vectors a, b, c with the circles of the size defined by the argument ‘Z’ and color specified by the argument ’Y.’

Examples of Matlab 3d scatter plot.

Let us now understand the code to use the scatter3 function in MATLAB.

Example #1

In this example, we will use the scatter3 function in its most basic form and plot a sine wave and a co-wave with random noise. Below are the steps to be followed:

  1. Define the random noise
  2. Initialize the sin wave
  3. Initialize the cos wave

Code:

c = linspace(0, 2 * pi, 100);
[Initializing the random noise]a = sin(c) + rand(1, 100);
[Initializing the sine wave]b = cos(c) + rand(1, 100);
[Initializing the cos wave]scatter3(a, b, c)
[Using the scatter3 function to plot the input waves]

This is how our input and output will look like in MATLAB:

Input:

Matlab 3d scatter plot | Learn the Examples of Matlab 3d scatter plot (2)

Output:

Matlab 3d scatter plot | Learn the Examples of Matlab 3d scatter plot (3)

As we can see in the output, we have obtained a 3D scatter plot for our input waves using the scatter3 function.

Example #2

Next, we will learn how to control the size of the circles in the scatter plot generated using the scatter3 function. For this, we will pass the required size as the 4th argument to the scatter3 function.

Code:

c = linspace(0, 2 * pi, 100);
[Initializing the random noise]a = sin(c) + rand(1, 100);
[Initializing the sine wave]b = cos(c) + rand(1, 100);
[Initializing the cos wave]scatter3(a, b, c, 50)
[Using the scatter3 function to plot the input waves. Please note that we have passed ‘50’ as the 4th argument which defines the size of the circles in the plot]

This is how our input and output will look like in MATLAB:

Input:

Matlab 3d scatter plot | Learn the Examples of Matlab 3d scatter plot (4)

Output:

Matlab 3d scatter plot | Learn the Examples of Matlab 3d scatter plot (5)

As we can see in the output, we have obtained a 3D scatter plot for our input waves using the scatter3 function. Also, the size of the circles in the plot is now larger in comparison to the plot in Example 1.

Example #3

In the above two examples, the color of the circles obtained is blue. Let us see how to change this color as per our requirements. In this example, we will plot a logarithmic function and an exponential function with random noise. Below are the steps to be followed:

  1. Define the random noise
  2. Initialize the logarithmic function
  3. Initialize the exponential function

Code:

c = linspace(0, 2 * pi, 100);
[Initializing the random noise]a = log(c) + rand(1, 100);
[Initializing the log function]b = exp(c) + rand(1, 100);
[Initializing the exponential function]scatter3(a, b, c, 50, 'green')
[Using the scatter3 function to plot the input waves. Please note that the argument ‘green’ is used to get the circles of the scatter plot in green color]

This is how our input and output will look like in MATLAB:

Input:

Matlab 3d scatter plot | Learn the Examples of Matlab 3d scatter plot (6)

Output:

Matlab 3d scatter plot | Learn the Examples of Matlab 3d scatter plot (7)

As we can see in the output, we have obtained a 3D scatter plot for our input waves using the scatter3 function. Also, the color of the circles is ‘green’, as expected by us.

We can also get the circles of solid nature rather than transparent. For this, we will pass another argument ‘filled’.

Code:

c = linspace(0, 2 * pi, 100);
[Initializing the random noise]a = log(c) + rand(1, 100);
[Initializing the log function]b = exp(c) + rand(1, 100);
[Initializing the exponential function]scatter3(a, b, c, 50, 'green', 'filled')
[Using the scatter3 function to plot the input waves. Please note that the argument ‘filled’ is used to get the circles of the solid nature]

This is how our input and output will look like in MATLAB:

Input:

Matlab 3d scatter plot | Learn the Examples of Matlab 3d scatter plot (8)

Output:

Matlab 3d scatter plot | Learn the Examples of Matlab 3d scatter plot (9)

As we can see in the output, we have obtained a 3D scatter plot for our input waves using the scatter3 function. Also, the circles in the plot are of solid nature, as expected by us.

If we want to get the plot in some shape other than the circles, we again pass the required shape as an argument. For example, we can pass ‘star’ as an argument to create the plots using the ‘star’ shape.

Conclusion

  1. The scatter3 function is used in MATLAB to plot 3D scatter plots
  2. These plots are used to draw 3 variables in one plot
  3. We can control the size, shape and other properties of the plotted points using the arguments of the scatter3 function

Recommended Articles

This is a guide to Matlab 3d scatter plot. Here we discuss the Examples of Matlab 3d scatter plot along with the code to use the scatter3 function in MATLAB. You may also have a look at the following articles to learn more –

  1. What is Matlab?
  2. Nyquist Matlab
  3. Plot graph Matlab
  4. Arctan Matlab

ADVERTIsem*nT

SPSS - Specialization | 14 Course Series | 5 Mock Tests 42 of HD Videos 14 Courses Verifiable Certificate of Completion Lifetime Access4.5

ADVERTIsem*nT

MICROSOFT AZURE - Specialization | 15 Course Series | 12 Mock Tests 73 of HD Videos 15 Courses Verifiable Certificate of Completion Lifetime Access4.5

ADVERTIsem*nT

HADOOP - Specialization | 32 Course Series | 4 Mock Tests 170 of HD Videos 32 Courses Verifiable Certificate of Completion Lifetime Access4.5

ADVERTIsem*nT

INFORMATICA - Specialization | 7 Course Series 69 of HD Videos 7 Courses Verifiable Certificate of Completion Lifetime Access4.5
Primary Sidebar

");jQuery('.cal-tbl table').unwrap("

");jQuery("#mobilenav").parent("p").css("margin","0");jQuery("#mobilenav .fa-bars").click(function() {jQuery('.navbar-tog-open-close').toggleClass("leftshift",7000);jQuery("#fix-bar").addClass("showfix-bar");/*jQuery(".content-sidebar-wrap").toggleClass("content-sidebar-wrap-bg");jQuery(".inline-pp-banner").toggleClass("inline-pp-banner-bg");jQuery(".entry-content img").toggleClass("img-op");*/jQuery("#fix-bar").toggle();jQuery(this).toggleClass('fa fa-close fa fa-bars');});jQuery("#mobilenav .fa-close").click(function() {jQuery('.navbar-tog-open-close').toggleClass("leftshift",7000);jQuery("#fix-bar").removeClass("showfix-bar");jQuery("#fix-bar").toggle();jQuery(this).toggleClass('fa fa-bars fa fa-close');/*jQuery(".content-sidebar-wrap").toggleClass("content-sidebar-wrap-bg");jQuery(".inline-pp-banner").toggleClass("inline-pp-banner-bg");jQuery(".entry-content img").toggleClass("img-op");*/});});

Matlab 3d scatter plot | Learn the Examples of Matlab 3d scatter plot (2024)

FAQs

How to plot a 3D plot in MATLAB? ›

To plot a 3D surface from a data file in MATLAB, you will need to have the data file open in MATLAB. Once you have the data file available, you can use the plot3 command to plot the data. The plot3 command will create a 3D plot of the data. You can also use the surf command to create a 3D surface plot.

What is a 3 dimensional scatter plot? ›

3D scatter plots are used to plot data points on three axes in the attempt to show the relationship between three variables. Each row in the data table is represented by a marker whose position depends on its values in the columns set on the X, Y, and Z axes.

What is the X Y Z scatter plot? ›

An XYZ class scatter plot is a scatter plot with symbols that mark the intersection of X, Y, and Z column data based on a required fourth value (Class column). Class scatter plots group data into discrete classes (bins). The data points are displayed using the symbol assigned to the class.

What is the formula for a 3D plot? ›

3D plot are generated from data defined as Z=f(X,Y). As for 2D plots, there are two ways to obtain a 3D plot depending on the way the (X,Y,Z) values are defined: You can have your Z values in a matrix.

What is the point size of scatter3? ›

scatter3(x,y,z) creates a scatter plot with markers at the locations specified by x , y , and z . The default type of the marker is a circle, the default color is "blue" and the default marker size is 36. This means the circle surrounding the marker has an area of 36 points squared.

How to run a MATLAB example? ›

Once the example is open, run it by clicking Run . To run the example one section at a time and view the incremental results, select the first section and then step through the script by clicking Run and Advance . Additional examples, created by members of the MATLAB community, are available at the File Exchange.

What are the 3 types of scatter graphs? ›

The three types of scatter diagrams
  • Positive correlation. If variables have a positive correlation, this signifies that when the independent variable's value rises, the dependent variable's value rises as well. ...
  • Negative correlation. ...
  • No correlation.
Jan 18, 2022

What 3 things does a scatter plot reveal? ›

A scatterplot displays the strength, direction, and form of the relationship between two quantitative variables. A correlation coefficient measures the strength of that relationship.

What is a scatter plot with an example? ›

A scatter plot (aka scatter chart, scatter graph) uses dots to represent values for two different numeric variables. The position of each dot on the horizontal and vertical axis indicates values for an individual data point. Scatter plots are used to observe relationships between variables.

How to interpret a scatter plot? ›

First, to read a scatter plot, make sure you understand what the independent (x-axis) and dependent variables (y-axis) are measuring. Next, we examine the view to see if we can identify a correlation between fields in the view. If the variables correlate they will fall along a line or curve.

How to plot xyz data in MATLAB? ›

Create x and y as vectors of random values between 0 and 1 . Create z as a vector of random duration values. x = rand(1,10); y = rand(1,10); z = duration(rand(10,1),randi(60,10,1),randi(60,10,1)); Plot x , y , and z , and specify the format for the z-axis as minutes and seconds.

How to create a 3D model in MATLAB? ›

Accepted Answer

In MATLAB, the patch function can be used to generate a 3D model by specifying the vertices and faces of the object. This function provides a convenient way to plot and visualize 3D objects in MATLAB. patch('Vertices', vertices, 'Faces', faces, 'FaceColor','red');

How to plot a 3D graph in MATLAB using Excel data? ›

Please follow the following steps:
  1. Prepare Your Excel File: Ensure your Excel file is organized such that it represents a grid of Z values. ...
  2. Read Data from Excel File: Use the readmatrix function to read the data from the Excel file into MATLAB.
  3. Extract X, Y, and Z Data: ...
  4. Plot the Surface:
Jun 26, 2024

Which command is used to plot a 3D surface in MATLAB? ›

surf( X , Y , Z ) creates a three-dimensional surface plot, which is a three-dimensional surface that has solid edge colors and solid face colors. The function plots the values in matrix Z as heights above a grid in the x-y plane defined by X and Y .

Top Articles
The 5 Worst Soups for Weight Loss (and 5 to Try Instead)
Shake ‘n Pour™ Buttermilk Pancake Mix
Spasa Parish
The Machine 2023 Showtimes Near Habersham Hills Cinemas
Gilbert Public Schools Infinite Campus
Rentals for rent in Maastricht
159R Bus Schedule Pdf
Understanding British Money: What's a Quid? A Shilling?
Officially Announcing: Skyward
Momokun Leaked Controversy - Champion Magazine - Online Magazine
Maine Coon Craigslist
How Nora Fatehi Became A Dancing Sensation In Bollywood 
‘An affront to the memories of British sailors’: the lies that sank Hollywood’s sub thriller U-571
Haverhill, MA Obituaries | Driscoll Funeral Home and Cremation Service
Rogers Breece Obituaries
Ella And David Steve Strange
Ems Isd Skyward Family Access
Elektrische Arbeit W (Kilowattstunden kWh Strompreis Berechnen Berechnung)
Omni Id Portal Waconia
Banned in NYC: Airbnb One Year Later
Four-Legged Friday: Meet Tuscaloosa's Adoptable All-Stars Cub & Pickle
Patriot Ledger Obits Today
Harvestella Sprinkler Lvl 2
Storm Prediction Center Convective Outlook
Experience the Convenience of Po Box 790010 St Louis Mo
modelo julia - PLAYBOARD
Poker News Views Gossip
Abby's Caribbean Cafe
Joanna Gaines Reveals Who Bought the 'Fixer Upper' Lake House and Her Favorite Features of the Milestone Project
Pull And Pay Middletown Ohio
Navy Qrs Supervisor Answers
Trade Chart Dave Richard
Sweeterthanolives
How to get tink dissipator coil? - Dish De
Lincoln Financial Field Section 110
1084 Sadie Ridge Road, Clermont, FL 34715 - MLS# O6240905 - Coldwell Banker
Kino am Raschplatz - Vorschau
Classic Buttermilk Pancakes
Pick N Pull Near Me [Locator Map + Guide + FAQ]
'I want to be the oldest Miss Universe winner - at 31'
Gun Mayhem Watchdocumentaries
Ice Hockey Dboard
Infinity Pool Showtimes Near Maya Cinemas Bakersfield
Dermpathdiagnostics Com Pay Invoice
A look back at the history of the Capital One Tower
Alvin Isd Ixl
Maria Butina Bikini
Busted Newspaper Zapata Tx
Rubrankings Austin
2045 Union Ave SE, Grand Rapids, MI 49507 | Estately 🧡 | MLS# 24048395
Upgrading Fedora Linux to a New Release
Latest Posts
Article information

Author: Otha Schamberger

Last Updated:

Views: 5874

Rating: 4.4 / 5 (75 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Otha Schamberger

Birthday: 1999-08-15

Address: Suite 490 606 Hammes Ferry, Carterhaven, IL 62290

Phone: +8557035444877

Job: Forward IT Agent

Hobby: Fishing, Flying, Jewelry making, Digital arts, Sand art, Parkour, tabletop games

Introduction: My name is Otha Schamberger, I am a vast, good, healthy, cheerful, energetic, gorgeous, magnificent person who loves writing and wants to share my knowledge and understanding with you.