Description Usage Arguments Details Note Author(s) See Also Examples
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. The x-y plot axes may be optionally displayed with logarithmic (base 10) scaling. Optionally a legend may be displayed on the plot.
Where the x-y data are parts from a composition they should be plotted as symmetric coordinates, and the third variable as a log-ratio if it is from the same composition.
1 2 3 4 5 | xyplot.z(xx, yy, zz, p = 0.5, sfact = 2.5, zmin = NA, zmax = NA, log = NULL,
xlim = NULL, ylim = NULL, xlab = deparse(substitute(xx)),
ylab = deparse(substitute(yy)), zlab = deparse(substitute(zz)),
main = "", col = 1, iflgnd = FALSE, title = deparse(substitute(zz)),
cex.lgnd = 0.8, ifparams = FALSE, cex.params = 0.8, ...)
|
xx |
name of the x-axis variable. |
yy |
name of the y-axis variable. |
zz |
name of the third variable, z, to be plotted. |
p |
a parameter that controls the rate of change of symbol diameter with changing value. A default of |
sfact |
controls the absolute size of the plotted symbols, by default |
zmin |
a value below which all symbols will be plotted at the same minumum size. By default |
zmax |
a value above which all symbols will be plotted at the same maximum size. By default |
log |
if it is required to display the data with logarithmic axis scaling, set |
xlim |
user defined limits for the x-axis, see Details below. |
ylim |
user defined limits for the y-axis, see Details below. |
xlab |
by default the character string for |
ylab |
by default the character string for |
zlab |
by default, |
main |
an alternative plot title, see Details below. |
col |
the colour of the symbols, the default is black, |
iflgnd |
the default is no legend. If a legend is required set |
title |
a short title for the legend, e.g., |
cex.lgnd |
controls the scaling of the legend box and text, but not the symbols so that they match those on the plot, the default is |
ifparams |
if |
cex.params |
controls the size of the text for the parameters display, defaults to |
... |
further arguments to be passed to methods. For example, if it is required to make the plot title smaller, add |
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 a 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. To obtain a logarithmic scaling set p = 0.3679
, i.e. 1/e
, and a value of p = 0.5
is equivalent to a square root transformation, the default, that is appropriate for a linear-area relationship. These values of p
are equivalent to plotting log(x)
or log10(x)
and sqrt(x)
, respectively. Experimentation is often necessary to obtain a satisfactory visual effect. See syms.pfunc
for a graphic demonstrating the effect of varying the p
parameter.
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 outlier(s) 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 symbol diameters vary. Note: If the variable z
includes a transform, e.g., log10(z)
, the values of zmin
and/or zmax
must be in those transform units.
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
.
For compositional data the function gx.symm.coords.mat
is required, and arguments xx
and yy
are replaced by a call to that function which returms the symmetric coordinated for those parts of the composition, and the axes should be labelled appropriately. See example below.
Any less than detection limit values represented by negative values, or zeros or other numeric codes representing blanks in the data, must be removed prior to executing this function, see ltdl.fix.df
.
The legend consists of five proportional symbols and their corresponding z
values: zmin
; the three quartiles; and zmax
. If zmin
and zmax
have been user defined it is over their range that the symbol sizes are computed and displayed. When defining zmin
and/or zmax
it is useful to set ifparams = TRUE
as a reminder, whilst developing the required display.
Any data vectors containing NA
s are removed prior to displaying the plot.
Robert G. Garrett
syms
, syms.pfunc
, ltdl.fix.df
, remove.na
, display.lty
, gx.symm.coords.mat
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
## Make test data available
data(sind)
attach(sind)
## Display a default symbol plot, p = 0.5 and sfact = 2.5
xyplot.z(Fe, Mn, Zn)
## Plot with logarithmically scaled symbols and more appropriately
## labelled axes
xyplot.z(Fe, Mn, log10(Zn), p = 1, log = "y",
xlab = "Fe (pct) in stream sediment",
ylab = "Mn (mg/kg) in stream sediment")
## 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\nZn (mg/kg)", symcolr = 2)
## Plot as above but where 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\nZn (mg/kg)", symcolr = 2)
## Detach test data
detach(sind)
rm(sind)
## More appropriately for compositional data
data(nockolds)
attach(nockolds)
## Plot a minor element against the symmetric coordinates for Si and Al, use
## p = 0.3679 to achieve a log ratio
xyplot.z(gx.symm.coords.mat(nockolds, 1, 2), P/Ti, p = 0.3679)
## Detach test data
detach(nockolds)
rm(nockolds)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.