Learn R Programming

rgr (version 1.1.0)

xyplot.z: Display a Third Variable in a X-Y Plot using Proportional Symbols

Description

Displays a third variable where the data are represented by open circles whose diameters are proportional to the value of the data at their x-y locations. The rate of change of symbol diameter with value and the absolute size of the symbols are defined by the user.

Usage

xyplot.z(xx, yy, zz, p = 1, sfact = 1, zmin = NA, zmax = NA, log = NULL, 
	xlim = NULL, ylim = NULL, xlab = deparse(substitute(xx)), 
	ylab = deparse(substitute(yy)), zlab = deparse(substitute(zz)), 
	main = "", iflgnd = FALSE, symcolr = 1, cex = 0.8, ...)

Arguments

xx
name of the x-axis variable.
yy
name of the y-axis variable.
zz
name of the third variable to be plotted.
p
a parameter that controls the rate of change of symbol diameter with changing value. A default of p = 1 is provided that results in a linear rate of change. See Details below.
sfact
controls the absolute size of the plotted symbols, by default sfact = 1. Increasing sfact results in larger symbols.
zmin
a value below which all symbols will be plotted at the same minumum size. By default zmin = NA which results in the minimum value of the variable defining the minimum symbol size. See Details below.
zmax
a value above which all symbols will be plotted at the same maximum size. By default zmax = NA which results in the maximum value of the variable defining the maximum symbol size. See Details below.
log
if it is required to display the data with logarithmic axis scaling, set log = "x" for a logarithmically scaled x-axis, log = "y" for a logarithmically scaled y-axis, and log = "xy" for both axes logarithmically scal
xlim
user defined limits for the x-axis, see Details below.
ylim
user defined limits for the y-axis, see Details below.
xlab
the x-axis title, by default the variable name, deparse(substitute(xx)). It is often desirable to replace the default x-axis title of the input variable name text string with a more informative title, e.g., xlab = "Fe (mg/kg) in stream
ylab
the y-axis title, by default the variable name, deparse(substitute(yy)). It is often desirable to replace the default y-axis title of the input variable name text string with a more informative title, e.g., ylab = "Mn (mg/kg) in stream
zlab
by default, zlab = deparse(substitute(zz)), a plot title is generated by appending the input variable name text string to Proportional Symbol Plot for. Alternative titles may be generated, see Details below.
main
an alternative plot title, see Details below.
iflgnd
if iflgnd = TRUE on completion of plotting the cursor is activated, locate that at in the centre of the space where the legend is to be added and left button on the pointing device. The legend comprises the third variable na
symcolr
the colour of the symbols, the default is black, symcolr = 1. This may be changed if required, see display.lty for the default colour palette. For example, symcolr = 2 will c
cex
the scaling factor for the legend, see above in iflgnd. By default it is set to cex = 0.8, it may be changed if required.
...
further arguments to be passed to methods. For example, if smaller plotting characters are required for the legend, specify, for example, cex = 0.8; and if some other colour than black is required for the legend, specify, for example,

Details

The symbol diameter is computed as a function of the value z to be plotted: diameter = dmin + (dmax - dmin) * {(z - zmin)/(zmax - zmin)}^p where dmin and dmax are defined as 0.1 and 1 units, so the symbol diameters range over an order of magnitude (and symbol areas over two); zmin and zmax are the observed range of the data, or the range over which the user wants the diameters to be computed; and p is a power defined by the user. The value of (z - zmin)/(zmax - zmin) is the value of z normalized, 0 - 1, to the range over which the symbol diameters are to be computed. After being raised to the power p, which will result in number in the range 0 to 1, this value is multiplied by the permissable range of diameters and added to the minimum diameter. This results in a diameter between 0.1 and 1 units that is proportional to the value of z. A p value of 1 results in a linear rate of change. Values of p less than unity lead to a rapid intial rate of change with increasing value of z which is often suitable for displaying positively skewed data sets, see the example below. In contrast, values of p greater than unity result in an initial slow rate of change with increasing value of z which is often suitable for displaying negatively skewed data sets. Experimentation is usually necessary to obtain a satisfactory visual effect. See syms.pfunc for a graphic demonstrating the effect of varying the p parameter. The user may choose to transform the variable to be plotted prior to determining symbol size etc., e.g. log10(zz), to generate a logarithmic rate of symbol size change. See Example below. If zmin or zmax are defined this has the effect of setting a minimum or maximum value of z, respectively, beyond which changes in the value of z do not result in changes in symbol diameter. This can be useful in limiting the effect of one or a few extreme outliers while still plotting them, they simply plot at the minimum or maximum symbol size and are not involved in the calculation of the range of z over which the diameter varies. If zlab and main are undefined a default a plot title is generated by appending the input variable name text string to "Proportional Symbol Plot for ". If no plot title is required set zlab = "", and if some user defined plot title is required it should be defined in main, e.g. main = "Plot Title Text". If the default selection for xlim is inappropriate it can be set, e.g., xlim = c(0, 200) or c(2, 200), the latter being appropriate for a logarithmically scaled plot, i.e. log = "x". If the defined limits lie within the observed data range a truncated plot will be displayed. The same procedure applies to setting ylim.

See Also

syms, syms.pfunc, ltdl.fix.df, remove.na, display.lty

Examples

Run this code
## Make test data available
data(sind)
attach(sind)

## Display a default symbol plot
xyplot.z(Fe, Mn, Zn)

## Plot with differently scaled symbols in red and more appropriate
## scaling and labelling with a user specified title
xyplot.z(Fe, Mn, Zn, p = 0.3, sfact = 2.0, log = "y",
	xlab = "Fe (pct) in stream sediment",
	ylab = "Mn (mg/kg) in stream sediment",
	main = "Howarth & Sinding-Larsen Test Data
Zn (mg/kg)", symcolr = 2) 

## Plot as above but with outliers above a value of 1000 displayed
## with the same symbol
xyplot.z(Fe, Mn, Zn, p = 0.3, sfact = 2.0, zmax = 1000, log = "y",
	xlab = "Fe (pct) in stream sediment",
	ylab = "Mn (mg/kg) in stream sediment", 
	main = "Howarth & Sinding-Larsen Test Data
Zn (mg/kg)", symcolr = 2) 

## Plot with logarithmically scaled symbols
xyplot.z(Fe, Mn, log10(Zn), sfact = 2.0, log = "y",
	xlab = "Fe (pct) in stream sediment",
	ylab = "Mn (mg/kg) in stream sediment") 

## Detach test data
detach(sind)

Run the code above in your browser using DataLab