Description Usage Arguments Details Value Author(s) See Also Examples
Methods for plotting process data contained in objects of class
ContinuousProcess
,
MarkedPointProcess
or
JumpProcess
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## S4 method for signature 'ContinuousProcess'
plot(x, nPoints = 200, ...)
## S4 method for signature 'MarkedPointProcess,character'
plot(x, y, nPoints = 200, ...)
## S4 method for signature 'JumpProcess'
plot(x, nPoints = 200, ...)
## S4 method for signature 'ProcessPlotData'
plot(x, ...)
## S4 method for signature 'ContinuousProcess'
getPlotData(object, y = '@bottom', nPoints = 200,
allUnitData = FALSE, selectPoints = NULL, dropLevels = 1, ...)
## S4 method for signature 'MarkedPointProcess,character'
getPlotData(object, y = '@mark', nPoints = 200, allUnitData = FALSE,
allMarkValueData = isTRUE(y %in% names(getMarkValue(object))), ...)
## S4 method for signature 'JumpProcess'
getPlotData(object, nPoints = 200, ...)
|
x |
process object to be plotted. |
y |
a |
object |
process object for which to compute a data set for plotting. |
nPoints |
a |
allUnitData |
a |
allMarkValueData |
a |
selectPoints |
a |
dropLevels |
a |
... |
other arguments. |
The underlying plotting engine is ggplot
from the ggplot2
package. The result of a call to plot
is thus a ggplot
object, which can be altered and plotted like any other ggplot
object.
The default plot is a plot of the (multivariate) process data held in
the process object x
divided according to the observation units
– the individuals. This is most suitable with relatively few units.
The plot
methods rely on the data structure to determine
sensible aesthetic mappings of the data for visualization. Hence,
numeric columns in a ContinuousProcess
object are plotted as
continuous sample paths of processes, factor columns are plotted as
bars at different levels and event columns in a
MarkedPointProcess
object are plotted as points. We refer to
the former as a ‘Continuous’ type data and the latter two as
‘Track’ data. The plot
methods attempt to compute a
sensible y-axis to plot either one of the types of data or the
combination of ‘Continuous’ and ‘Track’ data.
Modifications to the resulting plot can be done by a combination of
arguments to the plot
methods or subsequent manipulations of
the ggplot2
objects. For instance, with many units and p
the value of the plot
call, the plot
p + facet_null()
can be a useful alternative to the default. For ContinuousProcess
objects
with many units and few variables, one can also consider
p + facet_grid(variable ~ .)
while for a MarkedPointProcess
a possible alternative is
plot(object, y = "id") + facet_grid(variable ~ ., scale = "free_y")
For JumpProcess
objects one can in principle proceed as for a
ContinuousProcess
objects. However, when plotting the process
with discontinuities at the jump times the curve for each unit becomes
disconnected. A better alternative then, assuming that the unit
identification variable is id
, is
p + facet_grid(variable ~ .) + aes(color = id)
See demo(examples, package = "ppstat")
for examples. Some
aspects of the ggplot
objects are not that easily modified after
the object has been created. See below for how to deal with some examples.
The y
argument controls the y-values used for plotting the
point process part of the data set when plotting a
MarkedPointProcess
object. Values '@top'
and
'@bottom'
place the points above or below, respectively, the
plot of the ContinuousProcess
part of the object. A numeric
value of y
, e.g. 0, results in a plot with all points at this
particular y-value. A name of a mark value variable places the points
at their corresponding mark value and a name of a continuous process
variable places the points on the continous process. The default,
'@mark'
, places the points at different levels on the y-axis
corresponding to the different marks, and the unit identification
variable name places the points at different levels on the y-axis
corresponding to the different units.
As descriped above, the factor columns of a process data object are
plotted with bars at the different levels of the factor. The
dropLevels
argument works like the specification of contrasts
in a linear model parametrization. That is, the default value of 1
means that the first level is dropped in the plot and bars are
plotted for the other levels.
Technically, a call to plot
for either of the S4 process data
classes above is a two step procedure. First a call to
getPlotData
that returns the ProcessPlotData
object,
and then a call of the plot
method for that object, which
constructs the resulting ggplot2
object. The
ProcessPlotData
class is, however, currently not exported, nor
is the getPlotData
methods. The user only needs to
understand that additional arguments to plot
should be named
and are passed on to the getPlotData
data extractors
and the plot
method for the ProcessPlotData
object.
The ‘Track’ types of data are plotted as layers on the plot
with their own data sets. In general, any argument for
geom_point
, e.g. shape
, used to create the event points
layer can be given as an argument of the form point_shape
appending ‘point_’ to the argument. Any argument for
geom_line
, e.g. size
, used to create the factor bars
layer can be given as an argument of the form factor_size
appending ‘factor_’ to the argument. See the examples below.
plot
returns a ggplot
object.
getPlotData
returns an object of class ProcessPlotData
,
which contains the data that is actually plotted.
Niels Richard Hansen, Niels.R.Hansen@math.ku.dk
ProcessData
, ContinuousProcess
,
MarkedPointProcess
,
JumpProcess
,
ProcessPlotData
,
ggplot
1 2 3 4 5 6 7 8 9 10 11 | ## Examples of plot usages are collected in a demo.
## Not run:
demo(examples, package = "processdata")
## End(Not run)
## Certain parameters used in the layers for the tracks can be specified
## when calling the plot method.
## Not run:
data(example, package = "processdata")
plot(pointExam, point_size = 4, point_shape = 15)
plot(factExam, factor_size = 1, factor_alpha = 0.5)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.