| 5.1.pems.plots | R Documentation |
Various plot functions and visualization tools
for use with pems objects.
#pemsPlot
pemsPlot(x, y = NULL, z = NULL, groups = NULL,
cond = NULL, ..., data = NULL,
units = TRUE, multi.y = "special",
fun.name="pemsPlot")
#associated functions
pemsXYZCondUnitsHandler(x, y = NULL, z = NULL,
cond = NULL, groups = NULL, data = NULL,
units = TRUE, ...,
fun.name = "pemsXYZCondHandler")
preprocess.pemsPlot(lattice.like = lattice.like,
units = units, ...)
panel.pemsPlot(..., loa.settings = FALSE)
panel.routePath(..., loa.settings = FALSE)
#WatsonPlot
WatsonPlot(speed, accel = NULL, z = NULL, ...,
data = NULL, cond = NULL, units = TRUE,
plot.type = 2, fun.name="WatsonPlot")
#associated functions
preprocess.WatsonPlot(lattice.like = lattice.like, ...)
panel.WatsonBinPlot(..., ref.line = TRUE,
process.panel = NULL, plot.panel = NULL,
omit.stopped = FALSE, process = TRUE,
plot = TRUE, loa.settings = FALSE)
panel.WatsonContourPlot(...,
plot.panel=NULL, process = TRUE,
plot = TRUE, loa.settings = FALSE)
panel.WatsonSmoothContourPlot(...,
plot.panel=NULL, process = TRUE,
plot = TRUE, loa.settings = FALSE)
#old plots
latticePlot(x = NULL, data = NULL, plot = lattice::xyplot,
panel = NULL, ..., greyscale = FALSE,
fun.name = "latticePlot")
panel.PEMSXYPlot(..., grid=NULL)
XYZPlot(x = NULL, ..., data = NULL, statistic = NULL,
x.res = 10, y.res = 20, plot = lattice::levelplot,
fun.name = "XYZPlot")
x, y, z, groups, cond |
(Various) The main plot elements. For new plots, these should be supplied individually,
e.g. for
For old plots, these must be formulae. For For See Notes and Examples. |
data |
(Optional |
units |
(Optional |
multi.y |
(character) |
... |
(Optional) Other arguments, typically passed on. This
includes, |
fun.name |
(Function management argument) |
panel, plot.panel, process.panel |
(Functions) These functions are used to generate
the content of individual plot panels.
Typically, all in-panel data processing and plotting
is carried out using |
lattice.like, plot, process, loa.settings |
(Various) Plot management elements. These can typically be ignored by most users, but allow plot developers to fine-tune plots. See Details below. |
speed, accel |
(Various) For |
ref.line |
(Logical or list) For |
omit.stopped |
(Logical or character) For |
plot.type |
(numeric) For |
greyscale |
(Logical) For older plots only, should the plot
be greyscale by default? This option resets
the |
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 |
pems.utils includes conventional (generic)
plot methods for pems and
pems.element objects. See
plot.pems and
plot.pems.element for further
details.
However, it also includes a range of higher-level
plotting functions developed for use with
pems data.
Early plots, e.g. latticePlot, only allowed
plot arguments using the
lattice formula format. While this is
flexible and very powerful system, some users
preferred the more conventional plot(x,y,..)
call format.
So, newer plots, e.g. pemsPlot, allow both
conventional plot and
lattice-style formula calls.
pemsXYZCondUnitsHandler handles the pems
information associated with the plots. This
routine is included as a discrete function within
this package and others are welcome to
use elsewhere for similar purposes.
edit(pemsPlot) to see it.
Newer plots use a combination of lattice
and loa functions to provide a range of
additional plotting options, such as integrated panel
and key management. See loa
documentation for further details.
preprocess... and panel... functions
handle pre-plot and in-plot elements
of plot generation. These use the loa
modification of the lattice
plotting framework.
See Notes, Examples and extra documentation: pems.plots.
By default, pemsPlot generates a bubble plot,
so it plots (x,y) points, and by default
color-grades and size-scales them according to
z if also supplied.
When supplied speed and accel data-series as
x and y cases, the WatsonPlot
generates various forms of Watson's classic
speed/accel frequency distribution
plot.
latticePlot and XYZPlot are general
purpose 'xy' and 'xyz' data plotting functions.
fortify is intended for use by ggplot2
functions when users are plotting data in
pems objects. See Notes.
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.
pemsPlot and WatsonPlot no longer
accept formula x, y, z inputs.
With all these functions I have tried to make the default plotting options as robust as possible. However, it is not always possible to test all the plot combines that users might try. So, please let me know if anything is not working nicely for you. Thanks.
General:
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 graph;
xlim and ylim to 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 control.
latticePlot:
The default plot option for latticePlot
is xyplot.
panel options for latticePlot: Default
panel.xyplot. The alternative panel,
panel.PEMSXYPlot supplied as part of this
package, adds a grid layer to a standard xy panel.
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 and
loa as building blocks.
XYZPlot:
The default plot option for latticePlot
is levelplot.
pemsPlot:
pemsPlot and subsequent plot functions use an
alternative convention. Here, plots include
separate process and plot steps.
This option allows the plot to pass on share the
results of in-panel calculations with other panels
and keys. The handling mechanism is part of the
loa package.
The reason for latticePlot, etc:
latticePlot combines a number of
lattice and latticeExtra function
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
these functions a helpful introduction and handy
'stop gap' while they are getting to grips with
the code behind trellis and panel structures.
Karl Ropkins
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 and iplot, help you to very
quickly explore your data. But, for me the trellis
framework of lattice
has always felt the most flexible.
See lattice, latticeExtra,
loa.
###########
##example 1
###########
## Not run:
#plotting pems with other packages
#base
plot(pems.1)
plot(pems.1$velocity)
#with lattice
require(lattice)
xyplot(velocity~local.time, data = pems.1, type = "l")
#with ggplot2
require(ggplot2)
qplot(time.stamp, velocity, data=pems.1)
ggplot(pems.1, aes(x = time.stamp, y = velocity)) + geom_line()
#etc
## End(Not run)
###########
##example 2
###########
#basic usage of latticePlot
latticePlot(velocity~local.time, data = pems.1, type = "l")
latticePlot(velocity~local.time, data = pems.1, col = "red",
pch = 20, panel = panel.PEMSXYPlot,
grid = list(col ="black", lty=2))
###########
##example 3
###########
#basic usage of XYZPlot
a <- calcAccel(velocity, local.time, data = pems.1, output="pems")
XYZPlot(~accel*velocity, data=a)
XYZPlot(~accel*velocity, data=a, plot = lattice::wireframe, shade=TRUE)
###########
##example 4
###########
#basic usage of pemsPlot
pemsPlot(local.time, velocity, data=pems.1, type="l")
###########
##example 5
###########
#basic usage of WatsonPlot
#Note: using 'a' generated in example 3
WatsonPlot(velocity, accel, data=a)
## Not run:
#omit.stopped for different handling of idling data
WatsonPlot(velocity, accel, data=a, omit.stopped="points")
WatsonPlot(velocity, accel, data=a, omit.stopped="cells")
#plot.type for different plot methods
WatsonPlot(velocity, accel, data=a, plot.type=1)
WatsonPlot(velocity, accel, data=a, plot.type=2)
WatsonPlot(velocity, accel, data=a, plot.type=3)
WatsonPlot(velocity, accel, data=a, plot.type=4)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.