A scatter plot is a type of plot that shows the relationship between two variables. In a scatter plot, individual data points are represented by markers on a two-dimensional graph. The position of each marker is determined by the values of the two variables for that data point.
In MATLAB, the scatter
function is used to create scatter plots. The scatter
function takes two arguments, representing the x-coordinates and y-coordinates of the data points. For example, to create a scatter plot of the points (1,2), (3,4), and (5,6), you could use the following commands:
x = [1 3 5];
y = [2 4 6];
scatter(x, y)
In addition to the x- and y-coordinates, the scatter
function also accepts a number of optional arguments that allow you to customize the appearance of the plot. For example, you can specify the color, size, and shape of the markers using the 'Color'
, 'SizeData'
, and 'Marker'
properties.
Here is an example that creates a scatter plot wiÏth red markers of size 10 and square shape:
x = [1 3 5];
y = [2 4 6];
scatter(x, y, 'Color', 'r', 'SizeData', 10, 'Marker', 's')
You can also add labels, titles, and a legend to your scatter plot. For example, the following commands will add a title, axis labels, and a legend to the previous plot:
x = [1 3 5];
y = [2 4 6];
scatter(x, y, 'Color', 'r', 'SizeData', 10, 'Marker', 's')
title('Scatter Plot Example')
xlabel('x')
ylabel('y')
legend('data')
There are many different types of scatter plots that can be used to represent different types of data. Some common types of scatter plots include:
In MATLAB, the scatter
function is used to create scatter plots. The scatter
function takes two arguments, representing the x-coordinates and y-coordinates of the data points.
Related tutorials curated for you
How to plot a Bode in MATLAB
MATLAB subplot
How to create a scatter plot in MATLAB
How to create a 3D plot in MATLAB
How to plot a line in MATLAB
How to plot colors in MATLAB
How to create a surface plot in MATLAB
Plot markers in MATLAB
How to plot a legend in MATLAB
How to plot points in MATLAB
MATLAB linspace