1.1.loaPlot | R Documentation |
loaPlot is a standard XYZ plotting function, where X and Y are the axes of a conventional XY plot and Z is an element (or elements if supplied in the form Z1 + Z2 + Z3...) visualized at associated XY coordinates. By default, loaPlot links Z to plot point size and color to generate a bubbleplot style output, or using modified plot calls other plot types.
loaPlot(x, data = NULL, panel = panel.loaPlot,
..., local.scales = FALSE, reset.xylims = TRUE,
load.lists = NULL, by.group = NULL, by.zcase = NULL,
preprocess = TRUE)
#standard panels
panel.loaPlot(..., loa.settings = FALSE)
panel.loaPlot2(..., loa.settings = FALSE)
panel.loa(..., loa.settings = FALSE)
#grids
panel.loaGrid(grid.x = NULL, grid.y = NULL,
xlim = NULL, ylim = NULL, ...,
grid = NULL, panel.scales = NULL)
x |
A formula with the general structure
|
data |
If supplied, the assumed source of elements of |
panel |
|
... |
Additional arguments are passed on to related functions. For This mechanism provides access to most common plot parameters, e.g. |
local.scales |
For |
reset.xylims |
For |
load.lists |
For |
by.group , by.zcase |
For |
preprocess |
For |
loa.settings |
For |
grid.x , grid.y , xlim , ylim , grid , panel.scales |
For |
loaPlot
provides lattice-style conditioning/handling for a range of
commonly used XYZ plotting options. It is perhaps easiest pictured as a
'mid point' alternative somewhere between the standard lattice
plot functions xyplot
and levelplot
.
The default form of the plot uses an extension of the subscripting methods described by Deepayan Sarkar in Chapter 5 of Lattice (see sections on scatterplots and extensions). The default output is a bubble plot (see example 1 below).
loaPlot
returns a trellis object, much like a conventional lattice
plot function.
panel.loaPlot2
and panel.loaPlot2
are alternative versions of
panel.loaPlot
that is currently under revision.
loaPlot
arguments by.group
and by.zcase
are currently in
revision. Please use with care.
Karl Ropkins
These functions make extensive use of code developed by others.
lattice: Sarkar, Deepayan (2008) Lattice: Multivariate Data Visualization with R. Springer, New York. ISBN 978-0-387-75968-5
RColorBrewer: Erich Neuwirth <erich.neuwirth@univie.ac.at> (2011). RColorBrewer: ColorBrewer palettes. R package version 1.0-5. http://CRAN.R-project.org/package=RColorBrewer
In loa
: panelPal
In other packages, see
lattice
: xyplot
; and levelplot
.
## Example 1
## Basic usage
loaPlot(Ozone~Solar.R*Temp|Wind>8,
data=airquality,
col.regions="Blues")
# Notes:
# Formula structure z ~ x * y |cond like levelplot.
# Data (and groups) assignment like in standard lattice plots.
# By default z is linked to col and cex.
# Unless overridden by user inputs or group or zcase setting.
# Plot passed via ...Handler functions to provide shortcut plot
# reworking, e.g. here colHandler handles color scales
# using col.region to generate a color range.
# (Here, arguments like "Blues" and c("green", "red") are
# allowed and handled using functions in the RColorBrewer
# package.)
# Formula stuctures:
# ~ x * y like xyplot y ~ x
# ~ x * y | cond like xyplot y ~ x | cond
# z ~ x * y like xyplot y ~ x, col=f(z), cex=f(z)
# z ~ x * y | cond like xyplot y ~ x | cond, col=f(z), cex=f(z)
# z ~ x * y, groups = g like xyplot y ~ x, groups=g, cex=f(z)
# z1 + z2 ~ x * y (zcases)
# etc
## Example 2
## Basic modifications
loaPlot(Ozone~Solar.R*Temp, groups=airquality$Wind>8,
data=airquality)
# When groups are applied, by default group id is linked to col.
# The follow example illustrates three options:
loaPlot(Ozone~Solar.R*Temp, groups=airquality$Wind>8,
data=airquality,
group.args=c("pch"), pch=c(1,4),
col="blue")
# notes:
# Here, group.args is used to change the default group arguments.
# (So, pch rather than col is used to identify groups.)
# pch is then assigned by group rather than by (x,y) case or z case.
# (See panelPal Help further further details of assignments in loa.)
# col supplied by the user supercedes the default z linkage.
# (So, here cex remains z scales but col is fixed as blue.)
## Example 3
## Key handling
loaPlot(Ozone~Solar.R*Temp, data=airquality,
col.regions=c("green", "red"))
# Key settings are by the key argument (as in lattice)
# or key... arguments via keyHandler and listLoad, so e.g.:
loaPlot(Ozone~Solar.R*Temp, data=airquality,
col.regions=c("green", "red"),
key.fun = draw.loaColorKey)
# Notes:
# By default the loaPlot uses draw.loaPlotZKey to generate
# its color key unless an alternative is supplied via key.fun.
# (Here, the draw.colorKey wrapper draw.loaColorKey is used to
# generate a color bar similar to that in levelplot.)
## Example 4
## panels
loaPlot(Ozone~Solar.R*Temp|Wind>8, data=airquality,
col.regions="Reds")
# The combined use of loaPlot, panelPal and appropriately configured
# panel functions provides automatical handling of a range of plot
# elements, e.g.:
loaPlot(Ozone~Solar.R*Temp|Wind>8, data=airquality,
col.regions="Reds", panel=panel.binPlot)
# Notes:
# Here, the choice of default key is set by the panel... function;
# the panel by default bins data by location and for each bin cell
# calculates the mean Ozone concentration just like a standard
# lattice panel would, but it also tracks these values (calculated
# within the panels) and scales panel-to-panel and panel-to-key
# so users do not have to do that retrospectively; and, finally,
# it retains in-panel calculations so users can recover them.
# (See associated helps for further details: ?panelPal about methods;
# and ?panel.binPlot about the panel function.)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.