2.4.pems.plots: Various plots for pems.utils

Description Usage Arguments Details Value Warning Note Author(s) References See Also Examples

Description

Various plot functions and visualization tools for pems objects.

Usage

 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)

Arguments

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 WatsonPlot, should the time the vehicle is idling be discarded before generating the WatsonPlot.

...

(Optional) Other arguments, currently passed on to plot and panel.

data

(Optional data.frame or pems object) The data source elements in x if not the current environment or a parent.

fun.name, hijack

(Various) pems.utils management settings, can typically be ignored by most users.

x

(Required formula) For flexible plots. pems.utils uses the formula method of the lattice package. For latticePlot plot calls take the form latticePlot(y ~ x | cond, ...). For XYZPlot plot calls take the form XYZPlot(Z~ y * x | cond, ...). See Details, Notes, Warnings and Examples.

plot, panel

(Optional functions) The functions to use to generate the plot framework and the individual plot panels. For latticePlot, these are by default the lattice functions xyplot and panel.xyplot. For XYZPlot, currently only plot is forced, and this is by default the lattice function levelplot

greyscale

(Logical) For latticePlot, should the plot be greyscale by default? This option resets the lattice color themes to greyscale while the plot is beging generated. So: (1) This only effects the plot itself, not subsequent plots; and, (2) any user resets overwrite this, e.g. latticePlot(..., greyscale=TRUE, col="red" will place red symbols on an overwise greyscale plot. See Warning.

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 XYZPlot, the function to use when evaluation the elements of each data bin.

x.res, y.res

(Numerics) when binning data with XYZPlot, the number of x- and y-axis bins to generate.

Details

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.

Value

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.

Warning

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.

Note

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.

Author(s)

Karl Ropkins

References

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 Also

See lattice.

Examples

 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)

pems documentation built on May 2, 2019, 5:20 p.m.

Related to 2.4.pems.plots in pems...