generate scatter plots - Maple Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Graphics : Statistics : Statistics/ScatterPlot
This page is an exact match for your search term. Click here to search for all help pages containing the term, "Scatterplot"

Statistics[ScatterPlot] - generate scatter plots

 Calling Sequence ScatterPlot(X, Y, options, plotoptions) ScatterPlot[interactive](X, Y)

Parameters

 X - first data sample Y - (optional) second data sample options - (optional) equation(s) of the form option=value where option is one of bandwidth, color, degree, fit, jitter, legend, lowess, robust, xerrors, or yerrors; specify options for generating the scatter plot plotoptions - options to be passed to the plots[display] command

Description

 • The ScatterPlot command generates a one or two-dimensional scatter plot for the specified data. Optionally, one can fit a curve or apply lowess smoothing to the data.
 • The first parameter, X, is the first data sample - given as a Vector or list.
 • The second parameter, Y, is the second data sample - given as a Vector or list.
 • If Y is not given, then X is plotted by itself, with every entry in it being given an associated y-value of 1.
 • Note that X and Y must have the same number of elements.

Examples

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$
 > $N:=200:$
 > $U:=\mathrm{Sample}\left(\mathrm{Normal}\left(0,1\right),N\right):$
 > $X:=⟨\mathrm{seq}\left(1..N\right)⟩:$
 > $Y:=⟨\mathrm{seq}\left(\mathrm{sin}\left(\frac{2\mathrm{π}i}{N}\right)+\frac{{U}_{i}}{5},i=1..N\right)⟩:$

The command to create the plot from the Plotting Guide using the data above is

 > $\mathrm{ScatterPlot}\left(X,Y\right)$

Apply lowess smoothing to the scatter plot.

 > $P:=\mathrm{ScatterPlot}\left(X,Y,\mathrm{lowess},\mathrm{degree}=3,\mathrm{thickness}=3,\mathrm{title}="Scatter Plot",\mathrm{legend}="Point data"\right):$
 > $Q:=\mathrm{plot}\left(\mathrm{sin}\left(\frac{2\mathrm{π}x}{N}\right),x=1..N,\mathrm{thickness}=3,\mathrm{color}="Niagara Green"\right):$
 > $\mathrm{plots}[\mathrm{display}]\left(P,Q\right)$

Add a fitted curve to the scatter plot.

 > $R:=\mathrm{ScatterPlot}\left(X,Y,\mathrm{fit}=\left[a{t}^{4}+b{t}^{3}+c{t}^{2}+dt+e,t\right],\mathrm{thickness}=3,\mathrm{legend}=\left[\mathrm{points}="Point data",\mathrm{fit}=\mathrm{typeset}\left("fit to a",{4}^{\mathrm{th}},"degree polynomial"\right)\right]\right):$
 > $\mathrm{plots}[\mathrm{display}]\left(R,Q\right)$

To make use of the one dimensional features, simply don't supply a second data sample.

 > $\mathrm{ScatterPlot}\left(Y,\mathrm{size}=\left[600,200\right]\right)$

In the above plot, all the y-values are one. To get a better sense of the density of the one dimensional data, use the jitter option.

 > $\mathrm{ScatterPlot}\left(Y,\mathrm{jitter},\mathrm{size}=\left[600,200\right]\right)$

If this view is now too sparse, a view option can be used to adjust it.

 > $\mathrm{ScatterPlot}\left(Y,\mathrm{jitter},\mathrm{view}=\left[-1.2..1.2,-0.75..1.75\right],\mathrm{size}=\left[600,200\right]\right)$

## Was this information helpful?

 Please add your Comment (Optional) E-mail Address (Optional) What is ? This question helps us to combat spam