Skip to Main Content Skip to Search
Product Documentation

plot::Scatterplotstatistical scatter plots

plot::Scatterplot(data) creates a scatter plot of the given data.

→ Examples

Calls:

plot::Scatterplot([x1, x2, ...], [y1, y2, ...], <a = amin .. amax>, Options)

plot::Scatterplot([[x1, x2, ...], [y1, y2, ...]], <a = amin .. amax>, Options)

plot::Scatterplot([x1, y1], [x2, y2], ..., <a = amin .. amax>, Options)

plot::Scatterplot([[x1, y1], [x2, y2], ...], <a = amin .. amax>, Options)

plot::Scatterplot(A, <a = amin .. amax>, Options)

plot::Scatterplot(s, <c1, c2>, <a = amin .. amax>, Options)

Parameters:

x1, y1, x2, y2, ...: 

the statistical data: numerical real values or arithmetical expressions of the animation parameter a
x1, y1, x2, y2, ... is equivalent to the attribute Data.

A

an array of domain type DOM_ARRAY or a matrix of category Cat::Matrix (e.g., of type matrix or densematrix) providing numerical real values or arithmetical expressions of the animation parameter a. The i-th row is regarded as the data point (x[i], y[i]). The array/matrix must have 2 columns. If more columns are provided, the superfluous columns are ignored. 
A is equivalent to the attribute Data.

s

a data collection of domain type stats::sample. The columns in s are regarded as x- and y-values, respectively. 
s is equivalent to the attribute Data.

c1, c2

column indices into s: positive integers. These indices, if given, indicate that only the specified columns in s should be used. If no column indices are specified, the first two columns in s are used as x and y-values, respectively.

See Also:

plot, plot::Bars2d, plot::Bars3d, plot::Boxplot, plot::copy, plot::Histogram2d, plot::Listplot, stats::correlation, stats::linReg

Details:

For two data points the calls plot::Scatterplot([a, b], [c, d]) and plot::Scatterplot([[a, b], [c, d]]) both yield plots of the two points (x_1, y_1) = (a, b) and (x_2, y_2) = (c, d), not of the points (x_1, y_1) = (a, c) and (x_2, y_2) = (b, d)!

Example 1

We plot some data samples:

xdata := [6, 9, 17,  0, 13, 9, 9, 12, 12, 12]:
ydata := [7, 8, 20,  2, 11, 8, 9, 12, 13, 15]:
b := plot::Scatterplot(xdata, ydata):
plot(b)

MuPAD graphics

We can modify the appearance of the scatter plot in various ways:

b::PointColor := RGB::Red:
b::PointSize := 3*unit::mm:
b::LineColor := RGB::Black:
b::LineWidth := 1*unit::mm:

plot(b)

MuPAD graphics

delete xdata, ydata, b:

Example 2

We analyze the relationship between the time students spent on preparing for a test and the result of the test. We collect the data in a matrix. Each row corresponds to a student. The first column describes the numbers of hours spent for the preparation, the second column contains the corresponding test score (points out of 100):

TimesAndScores := matrix([[ 1,  61],
                          [10,  75],
                          [4,   55],
                          [3,   18],
                          [4,   77],
                          [6,   72],
                          [3,   18],
                          [1,   25],
                          [0,   50],
                          [4,   68],
                          [4,   68],
                          [8,   87],
                          [9,   74],
                          [11,  79],
                          [6,   28],
                          [4,   65],
                          [7,   52],
                          [8,   78],
                          [2,   36],
                          [3,   48],
                          [4,   39]
                         ]):

We draw a scatter plot to identify a possible relationship between the two variables:

plot(plot::Scatterplot(TimesAndScores))

MuPAD graphics

There seems to be a relationship, indeed.

delete TimesAndScores:

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS