
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





Options



The options argument can contain one or more of the options shown below. All unrecognized options will be passed to the plots[display] command. See plot[options] for details.


This option is used to control the bandwidth of the lowess smoothing algorithm, when lowess fitting is enabled. The value of this option is the fraction of points used to define a neighborhood. If n is the number of points in the data sample passed to ScatterPlot, then the condition bandwidth*n>degree must be true. The default value is $\frac{1}{3}$.

•

color=name, list, or range


This option specifies colors for the individual data sets. When a list of colors is given, each of the scatters will be colored with the corresponding color in the list. If a range of colors is given, the colors will be generated by selecting an appropriate number of equallyspaced points in the corresponding hue range.


The degree of the polynomial used in lowess smoothing, when lowess fitting is enabled. If n is the number of points in the data sample passed to ScatterPlot, then the condition bandwidth*n>degree must be true. The default value is $1$.


One can specify a curve to be fitted into the data points. The value of this option is the list of arguments to be passed to the NonlinearFit command.


This option is for one dimensional data only. This option causes all points in X to be assigned a random yvalue in the range of [0, 1). This allows a better visual representation of the density of one dimensional data. The default for this option in false. Note that if Y is specified, this option is ignored.

•

legend=expression or list


This option controls whether a legend, or multiple legends, are created. The simplest form specifies only a legend entry for the points of the scatter plot. This is specified as legend = s, where s can be specified as explained in plot,typesetting. If the fit option and/or the lowess option are also specified, and a legend for the corresponding curves is desired, possibly in addition to a legend for the points, then this can be specified as legend = l, where l is a list of zero or more equations of the forms points = s1, fit = s2, or lowess = s3. The legends s1, s2, and s3 can be specified as explained in plot,typesetting.


Tells whether lowess smoothing should be applied to the scatter plot. The smoothing behavior is modified by the options bandwidth, degree and robust; see these options for more details. The default value is false.


This option tells whether the data weights in the lowess fitting should be adjusted for robustness. The default value is false.

•

xerrors=Vector or [Vector, Vector]


This options specifies errors along the xaxis. The array of errors must have the same number of elements. To specify right errors and left errors separately, use the list of two vectors.

•

yerrors=Vector or [Vector, Vector]


Similar to the xerrors option, see above.



Description


•

The ScatterPlot command generates a one or twodimensional 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 yvalue of 1.

•

Note that X and Y must have the same number of elements.



Examples


>

U := Sample(Normal(0, 1), N):

>

Y := <seq(sin(2*Pi*i/N)+U[i]/5, i = 1..N)>:

The command to create the plot from the Plotting Guide using the data above is
Show two scatterplots on the same plot.
>

plots:display(ScatterPlot(U,X,color="Red"), ScatterPlot(Y,X,color="Blue"));

Apply lowess smoothing to the scatter plot.
>

P := ScatterPlot(X, Y, lowess, degree = 3, thickness = 3, title="Scatter Plot", legend="Point data"):

>

Q := plot(sin(2*Pi*x/N), x = 1..N, thickness = 3, color = "Niagara Green"):

Add a fitted curve to the scatter plot.
>

R := ScatterPlot(X, Y, fit = [a*t^4+b*t^3+c*t^2+d*t+e, t], thickness = 3, legend=[points="Point data", fit = typeset("fit to a ", 4^th, "degree polynomial")]):

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

ScatterPlot(Y, size = [600,200]);

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

ScatterPlot(Y, jitter, size = [600,200]);

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

ScatterPlot(Y, jitter, view = [1.2 .. 1.2, 0.75 ..1.75], size = [600,200]);



Compatibility


•

The Statistics[ScatterPlot] command was updated in Maple 2015.



