Description Usage Arguments Details Value Warning Note Author(s) References See Also Examples
Various plot functions and visualization tools for pems
objects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #defined plots
WatsonPlot(speed = NULL, accel = NULL, time = NULL, distance = NULL,
drop.idle.time = TRUE, ..., data = NULL,
fun.name = "WatsonPlot", hijack= FALSE)
#flexible plots
latticePlot(x = NULL, data = NULL, plot = xyplot, panel = NULL,
..., greyscale = FALSE, fun.name = "latticePlot",
hijack = FALSE)
panel.PEMSXYPlot(..., grid=NULL)
XYZPlot (x = NULL, ..., data = NULL, statistic = NULL,
x.res = 10, y.res = 20, plot = levelplot,
fun.name = "XYZPlot", hijack = FALSE)
|
speed, accel, time, distance |
(data series, typically vectors) For defined plots, data series to be used to generate a given plot. Only some of these may be required. See Notes. |
drop.idle.time |
(logical) For |
... |
(Optional) Other arguments, currently passed on to |
data |
(Optional |
fun.name, hijack |
(Various) |
x |
(Required formula) For flexible plots. |
plot, panel |
(Optional functions) The functions to use to generate the plot framework and the individual
plot panels. For |
greyscale |
(Logical) For |
grid |
(List) If supplied, a list of plot parameters to be used to control the appearance of the grid component of the plot. See Below. |
statistic |
(Function) when binning data with |
x.res, y.res |
(Numerics) when binning data with |
Defined plots operate like the main R plot function, plot
. x
and y
data series are supplied as individual arguments: in the form plot(x, y)
.
The WatsonPlot
uses speed and acceleration data series as x
and y
inputs to generate a standard speed/acceleration frequency plot, but can accept a range of
different input combinations to generate this information, e.g.:
time and distance (time and distance -> speed, time and speed -> accel)
time and speed (time and speed -> accel)
speed and accel
Flexible plots operate like plots in the lattice
package, and define the
plot structure using a formula format/structure:
For latticePlot
the formula structure is y ~ x | cond
, where
y
is the data series to use as the y-axis, x
is the data series to
as the x-axis and cond
is an addition 'conditioning' data series which is
used to separate the data into different subplots.
For XYZPlot
the formula structure is Z~ y * x | cond
,
z
is the data series to use as the z-axis or z element of the plot,
y
is the data series to use as the y-axis, x
is the data series to
as the x-axis and cond
is an addition 'conditioning' data series which is
used to separate the data into different subplots. z
is optional, but When
it is not supplied z
it is treated as the bin count.
latticePlot
is a wrapper for a number of lattice
and
latticeExtra
plot function modifications that simplify routine
handling of plotted data. See Examples.
panel.PEMSXYPlot
is a simple gridded panel function intended for use
with the panel
argument of latticePlot
or lattice
plot functions directly.
XYZPlot
is a wrapper for a number of lattice
plot functions
that provide 'xyz' data visualisations.
See Examples, Warnings and Note.
WatsonPlot
generates a speed/acceleration frequency plot.
latticePlot
is a wrapper for various lattice
and
latticeExtra
functions that make nice graphs very quickly. It
generates trellis-style graphical outputs based on 'xy' data sets.
XYZPlot
generates trellis-style graphical outputs based on 'xyz' data
sets.
IMPORTANT: Conditioning is currently disabled on XYZPlot
.
XYZPlot
is a short-term replace for previous function quickPlot
. It will most likely
be replaced when pems.utils.0.3
is released.
The greyscale
argument is a recent addition to latticePlot. I think I have reset all
default colors, but may have missing something. Please let me know if you spot anything still
colored and I'll get it fixed as soon as possible. Thanks.
plot
options for latticePlot
: The default option is xyplot
.
panel
options for latticePlot
: The default option is panel.xyplot
. The
addition panel, panel.PEMSXYPlot
supplied as part of this package adds a grid layer
to a standard xy panel. It is simply made using two panels, panel.grid
and
panel.xyplot
, both in lattice
. edit{panel.PEMSXYPlot}
to have a look at
it. The extra code just allows you to pass specific plot parameters to the grid panel using
the argument grid
. You can build almost any plot layout using these and other panels
in lattice
as building blocks.
plot
options for XYZPlot
: The default option is levelplot
.
Other arguments: Like most other plot functions in R
, lattice
functions
use a number of common parameter terms. For example, xlab
and ylab
reset the x and
y labels of a grpah; xlim
and ylim
set the x- and y-scales of a graph; col
sets the color of a plot element; type
sets the type ('p' for points, 'l' for lines, etc);
pch
and cex
set plot symbol type and size, respectively; and, lty
and
lwd
set plot line type and thickness, respectively; etc. These terms are passed onto and
evaluated by all these plot functions to provide standard plot think control.
The reason for latticePlot
: latticePlot
combines a number of lattice
and
latticeExtra
functions of modifications I regularly use when plotting data. So, it is
basically a short cut to save having to write out a lot of code I regularly use. I would encourage
anyone to at the very least have a look at lattice
. I also hope those learning
lattice
, find latticePlot
a helpful introduction and handy 'stop gap' while they
are getting to grips with the code behind trellis and panel structures.
Karl Ropkins
Watson plots:
Watson, H.C., Effects of a wide range of drive cycles on the emissions from vehicles of three levels of technology. SAE Technical Paper Series. Paper No. 950221, 1995.
lattice:
Sarkar, Deepayan (2008) Lattice: Multivariate Data Visualization with R. Springer, New York. ISBN 978-0-387-75968-5
latticeExtra:
Deepayan Sarkar and Felix Andrews (2011). latticeExtra: Extra Graphical Utilities Based on Lattice. R package version 0.6-18. http://CRAN.R-project.org/package=latticeExtra
lattice
is one of number of really nice graphical tools in R
.
Others, like ggplot2
, hexplot
and iplot
, help you to very
quickly explore your data. But, for me the trellis framework of lattice
has always been the most flexible.
See lattice
.
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 | ###########
##example 1
###########
#basic usage of defined plots
WatsonPlot(velocity, time=local.time, data=pems.1)
###########
##example 2
###########
#basic usage of flexible plots
#latticePlot
latticePlot(velocity~local.time, data = pems.1, type = "l")
#in lattice, xyplot(velocity~local.time, data = getData(pems.1), type = "l")
#Note: to use lattice functions directly with pems objects
# just pass data component with data = getData(pems)
# (NOT data = pems)
latticePlot(velocity~local.time, data = pems.1, col = "red",
pch = 20, panel = panel.PEMSXYPlot,
grid = list(col ="black", lty=2))
#XYZPlot
a <- calcAccel(velocity, local.time, data =pems.1)
#like WatsonPlot
#(But with idle data included in plot)
XYZPlot(~accel*velocity, data=a)
XYZPlot(~accel*velocity, data=a, plot = wireframe, shade=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.