Create Scatter and List Plots

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Scatter plots can help you identify the relationship between two data samples. A scatter plot is a simple plot of one variable against another. For two discrete data samples x1, x2, ..., xn and y1, y2, ..., yn, a scatter plot is a collection of points with coordinates [x1, y1], [x2, y2], ..., [xn, yn]. To create a scatter plot in MuPAD®, use the plot::Scatterplot function. For example, create the scatter plot for the following data samples x and y:

x := [0.25, 0.295, 0.473, 0.476, 0.512,
     0.588, 0.629, 0.648, 0.722, 0.844]:
y := [0.00102, 0.271, 0.378, 0.478, 0.495,
      0.663, 0.68, 0.778, 0.948, 0.975]:
plot(plot::Scatterplot(x, y))

By default, the plot::Scatterplot function also displays a regression line. This line shows the linear dependency that best fits the two data samples. To hide the regression line, use the LinesVisible option:

plot(plot::Scatterplot(x, y, LinesVisible = FALSE))

Another plot that can help you identify the relationship between two discrete data samples is a list plot. List plots are convenient for plotting one data sample with equidistant x-values. They are also convenient for plotting combined data samples, such as [[x1, y1], [x2, y2], ..., [xn, yn]]. If you have two separate data samples, you can combine the data of these samples pairwise:

xy := [[x[i], y[i]] $ i = 1..10]:

To create a list plot, use the plot::Listplot function:

plot(plot::Listplot(xy), AxesTitles = ["x", "y"])

By default, the plot::Listplot function connects adjacent points on the plot by straight lines. To hide these connections, use the LinesVisible option:

     AxesTitles = ["x", "y"],
     LinesVisible = FALSE)