Line & Scatter Plots (2D)

The following two-dimensional plots are created using the Line/Scatter dialog:

Scatter

Line

Line with Scatter

Line Plot with Isolated Points

High Density Line Plots

Step Plot

Line with Text as Symbols

Y Series Line

Bubble

Color

Bubble Color

Loess Smoothing

Spline Smoothing

Robust LTS Smoothing

Robust MM Smoothing

Kernel Smoothing

Friedman Super Smoothing

Dot Plot

To open the Line/Scatter Plot dialog, click on any of the buttons on the Plots 2D palette listed above. For plots that do not have buttons on the palette, choose Graph __image\arrow5.gif 2D Plot from the main menu. Choose a plot type from the scrolling list.

This section describes the fields common to most of the 2D line and scatter plots. The dialogs show fields with the defaults for the scatter plot. For descriptions of fields unique to plot types, see the individual plot type topics.

Data to Plot page

__image\scatdia1.gif

In the Line/Scatter Plot dialog, the Data to Plot page has the following options:

Data

Data Columns

For line and scatter plots specify the names or column numbers of your X and Y columns. If you specify only one column of data (X or Y), an integer sequence is used for the missing column of data.

You can also specify a third column of data to vary the size, color, or style by the values in this column. See the Vary Symbols page for more information.

Override Conditioning

Type Select Auto to use the conditioning variables specified on the graph's multipanel page. Select None to use the full data set for this plot in each panel (no conditioning is used). This is useful if you would like to draw a reference plot in each panel. Select Specified Columns if you would like to override the specifications for the conditioning variables for this plot.

Data Set If Type is set to Specified Columns, specify the name of the data set containing the column to use for conditioning.

Column(s) If Type is set to Specified Columns, specify the variable name to use for conditioning.

Draw in Panels Select All to have the plot drawn in all panels, or select a panel number to have the plot drawn only in a single panel.

Data Tips and Point Labels

Choose one or more columns from the dropdown list to appear as DataTips when you hover the mouse over points in the plot.

Scale To

This option is available only for 2D plots; all 3D plots are scaled to only one set of available axes (X, Y, and Z).

X-Axis/Y-Axis # If you have multiple axis pairs on your graph, use the Scale to options to choose the x-axis and y-axis to be used for scaling the plot. Specify the number of the desired x-axis and y-axis. By default S-PLUS scales the plot to the first x-axis and y-axis on the graph.

If you specify an axis number that does not exist it is added automatically. For example, if you specify #2 for the Y axis # and you currently have only one y-axis, a second y-axis is added and the plot is scaled to it automatically.

For information on adding axes to a graph, see the section Formatting a Graph .

Plane # Many of the 2D plot types can be projected onto a 3D plane. To project a 2D plot, put the 2D plot on a 3D graph and specify the projection plane in the Plane # field. For information on projecting 2D plots see Projecting a 2D Plot onto a 3D Plane .

Stack 3D Contour This option is available only for Contour and Levels plots. Choose this option to have the contour plot stacked in 3D space. If this option is not selected, contours are drawn in 2D space.

Use for Aspect Ratio

Select this to have the plot incorporated into the aspect ratio calculations made by the graph object. Only certain 2D plots have this feature. Those 2D plots without this field are not considered in the calculations. Axis types other than 2D do not make these calculations. See the Position/Size page under Formatting the Plot Area for more information on aspect ratio calculations.

Hide

Select the Hide option to temporarily prevent a plot from displaying on a graph. When you hide a plot, all of the plot specifications are retained. A plot button remains on the graph representing the hidden plot. You can unhide a hidden plot by double-clicking on its plot icon and clearing the Hide checkbox.

Crop

Select the Crop option to have your 2D plots cropped at the edges of the plot area. Leave the checkbox empty to permit the plot to extend beyond the plot area. If cropping is on, any data, lines, or symbols extending beyond the plot area are not plotted.

Subset Rows with

You can also specify a subset of rows for graphing in the Subset Rows with field. Enter an expression that identifies the rows to use in the analysis. The expression must evaluate to a vector of logical values (TRUE values are used, FALSE values are dropped), or a vector of indices identifying the numbers of rows to use (for example, 1:20 or Age >=13).

Line page

__image\scatdia2.gif

In the Line/Scatter Plot dialog, the Line page has the following options:

Line attributes

Line Style Choose the line style (for example, dotted, dashed etc.) to be used, or None to have no line drawn.

Line Color Choose the color for a line. Choose from 16 preset colors or your own custom colors.

Line Weight Specify the line weight in points.

Connect Type

Choose an option to select a method to connect points. Choose Direct to create a standard line plot. Choose Isolated Points to allow space between line and symbols.

Break Line

at Missings Choose whether to break the plot line when it encounters a missing value. If this option is not selected, the plot line connects all data points, ignoring missing values.

at Symbols Choose whether to break the plot line when it encounters a data point symbol. This is useful when you do not want the plot line to bisect the symbol. If this option is not selected, the plot line is drawn through each symbol.

Draw Gridlines

Select Draw Gridlines to draw horizontal gridlines at major ticks to create a dot plot.

Symbol page

__image\scatdia3.gif

In the Line/Scatter Plot dialog, the Symbol page has the following options:

Symbol

Symbol attributes

Style Choose the symbol style to be used for plot symbols and extra symbols.

Color Choose the color for symbols.

Height Specify the height of a symbol, in inches/cm.

Line Weight Choose the line weight for outlining symbols.

Use Text as Symbols

Choose whether to use a user-specified string or column of text in any font as plotting symbols.

Symbol Frequency

Specify how frequently symbols are displayed on data points. To place a symbol at each data point, enter a 1; a value of 3 indicates that every third point is plotted with the symbol. If you choose 0, no symbols are plotted.

Jitter

Jitter Symbols Specify to introduce random 'noise' in a particular direction to the data plotted. Options include:

Neither No noise is incorporated.

X only Noise is added only to the X component of the plot.

Y only Noise is added only to the Y component of the plot.

Both Noise is added to both the X and Y components of the plot.

Jitter Factor The Jitter Factor is used to scale the range of added noise. The range for the Auto option is 1/50th of the difference between the minimum and maximum values of the data components specified in Jitter Symbols. For example, if a data component had a difference of 100 between the minimum and maximum, the default range would be between -2 and 2. Random numbers from this range are added to the original data and then plotted.

Entering a number in this field multiplies the range by that value. For example, if 10 is specified then the range will be 1/5th of the data range. If the data component has a difference of 100, then the range for the noise would be -20 to 20. The Jitter Factor value must be greater than zero. There is no upper limit for allowable value in this field, however if the value is too large the plot may fail to draw because none of the points fall within the range of the original data. If Both is specified in Jitter Symbols then the noise ranges for the X and Y components are calculated separately but the same factor is applied to both.

Text As Symbols

These fields become available when Use Text as Symbols is selected.

Text to Use Choose from Specified Text, x, y, z, w or Other Column. Choose Specified Text to type text into the Symbol Text box and use it for every symbol on the graph. Choose one of the column options to use a column of text as symbols.

Symbol Text Specify the text to be used as a symbol.

Column Choose a column of text to use.

Data Set Choose the data set containing the column of text.

Font Choose a font type for the text.

Bold, Italics, Underline Select text formatting options.

Vary Symbols page

__image\scatdia4.gif

In the Line/Scatter Plot dialog, the Vary Symbols page has the following options:

Vary Symbol By

Vary the symbols by size, color, or style. Choose from None, x, y, z, w or Other Column. The variation of the symbol is determined by the relative value of a third column. For example, if x is the gas mileage of a car and y is a measure of safety, symbol size could vary depending on price. The third column must be chosen in the z or w column on the Data To Plot page.

Vary Symbol Size

Minimum Height Specify the minimum size for the symbol.

Maximum Height Specify the maximum size for the symbol.

Column This field is available only when Other Column is chosen for Vary Size By. Choose a column from the dropdown list.

Data Set This field is available only when Other Column is chosen for Vary Size By. Choose a data set from the dropdown list.

Vary Symbol Style

Column This field is available only when Other Column is chosen for Vary Style By. Choose a column from the dropdown list.

Data Set This field is available only when Other Column is chosen for Vary Style By. Choose a data set from the dropdown list.

Vary Symbol Color

Colors To Use Choose from Range or Special (used only if the third column has numeric data). If you choose Special, the Special Colors button becomes available.

Minimum Color Minimum color in the shading range.

Maximum Color Maximum color in the shading range.

Column This field is available only when Other Column is chosen for Vary Color By. Choose a column from the dropdown list.

Data Set This field is available only when Other Column is chosen for Vary Color By. Choose a data set from the dropdown list.

Special Colors

Specify custom colors in the standard Color dialog. The Special Colors button is available only when Special Colors is chosen as the Fill Type. Click the button to open the Color dialog, where you can define a maximum of 16 colors.

Smooth/Sort page

__image\scatdia5.gif

In the Line/Scatter Plot dialog, the Smooth/Sort page has the following options:

Pre-Sort Data

Choose from "None", "X,Y on X", "X,Y on Y", "X only" and "Y only". If a sorting option is selected, data is sorted before any smoothing or rendering of the line is done.

Smoothing Type

Choose from the following options:

None uses no smoothing.

Least squares uses the lm function to perform a least squares linear fit.

Robust uses the ltsreg function to perform a least trimmed squares robust regression. This regression estimate minimizes the sum of the smallest half of the squared residuals.

Robust MM uses the lmRobMM function to perform a robust fit of a linear regression model. The Exhaustive resampling method is used.

Kernel uses the ksmooth function to perform a kernel smooth, which is a generalization of local average smoothing.

Loess uses the loess function to fit a local regression.

Spline uses the smooth.spline function and the predict.smooth.spline function to calculate predictions from a cubic B-spline. The regression is fit by penalized least squares between knots. For small data vectors (n < 50), a knot is placed at every distinct point. For larger data sets the number of knots is chosen judiciously in order to keep the computation time manageable.

Friedman's Super uses the supsmu function to compute Friedman's variable span smoother. It uses a symmetric k-nearest neighbor linear least squares fitting procedure. The algorithm is fast, and by default uses cross validation to pick the span. This allows the user to specify a smoothing function.

User smoothing type allows you to specify the function to use for smoothing.

Number Output Points

Specify the number of points to be produced by the smoothing. If Auto is selected, the number of output points is set to the maximum of 100 and the length of the input vectors.

Loess/Friedman Specs

Span Select a number between 0 and 1 that will be used to control the amount of smoothing. Smaller values result in less smoothing. Very small values close to 0 are not recommended. If Auto is selected, then automatic (variable) span selection is done by means of cross validation. Reasonable span values are from 0.3 to 0.5. For small samples (n < 50), or if there are substantial serial correlations between observations close in x-value, a prespecified fixed span smoother should be used.

Degree Select the overall degree of the locally-fitted polynomial. One is locally-linear fitting, and Two is locally-quadratic fitting.

Family Select either Symmetric or Gaussian. The Symmetric option combines local-fitting with a robustness feature that guards against distortion by outliers. The Gaussian option strictly employs local-fitting methods.

Smoothing Spline Specs

Deg. Of Freedom The degrees of freedom should be between 1 and the number of input data points minus 1. The lower the degrees of freedom, the smoother the line. If Auto is selected cross-validation is used.

Kernel Specs

Bandwidth Enter a numeric value for the kernel bandwidth smoothing parameter. All kernels are scaled so the upper and lower quartiles of the kernel are 0.25 and -0.25 when the bandwidth is 1. Larger values of bandwidth make smoother estimates, while smaller values make less smooth estimates. The default bandwidth is 0.5.

Kernel From the dropdown menu, choose Box (a rectangular box), Triangle (a box convolved with itself), Parzen (the parzen function - a box convolved with a triangle), or Normal (a gaussian density function). The default Kernel is Box.

User-Defined Smoothing Specs

Function Name Specify the name of the function to use for smoothing. The first arguments must be:

x: vector of x data

y: vector of y data

z: vector of z data (can be NULL)

w: vector of w data (can be NULL)

subscripts: vector of row indices

panelnum: panel number if conditioned

It must return a list containing the following components:

x: a vector of x data for line drawing

y: a vector of y data for line drawing

Other Arguments

For any of the smoothing types, any of the optional arguments can be specified here. For example, if Friedman's supersmoother is used, the underlying supsmu function is called. If bass=5 is put into the Other Arguments field, this is passed down to the supsmu function when calculated.

Output Data Set

Save Predicted Values Select to save the results in a data set.

Data Set Name If Save Predicted Values is selected, this field becomes enabled. Choose from the dropdown list or type in a name for the results data set.