Plots the events (prescribing or dispensing) data encapsulated in a basic CMA0 object.
# S3 method for CMA0
plot(x, ..., patients.to.plot = NULL, duration = NA,
align.all.patients = FALSE, show.period = c("dates", "days")[2],
period.in.days = 90, show.legend = TRUE, legend.x = "right",
legend.y = "bottom", legend.bkg.opacity = 0.5, legend.cex = 0.75,
legend.cex.title = 1, cex = 1, cex.axis = 0.75, cex.lab = 1,
col.cats = rainbow, lty.event = "solid", lwd.event = 2,
pch.start.event = 15, pch.end.event = 16, print.dose = FALSE,
cex.dose = 0.75, print.dose.outline.col = "white",
print.dose.centered = FALSE, plot.dose = FALSE,
lwd.event.max.dose = 8,
plot.dose.lwd.across.medication.classes = FALSE,
col.continuation = "black", lty.continuation = "dotted",
lwd.continuation = 1, col.na = "lightgray",
highlight.followup.window = TRUE, followup.window.col = "green",
highlight.observation.window = TRUE,
observation.window.col = "yellow", observation.window.density = 35,
observation.window.angle = -30, observation.window.opacity = 0.3,
bw.plot = FALSE, print.CMA = TRUE, plot.CMA = TRUE,
CMA.plot.ratio = 0.1, min.plot.size.in.characters.horiz = 10,
min.plot.size.in.characters.vert = 0.5, max.patients.to.plot = 100)
A CMA0
or derived object, representing the CMA to
plot
other possible parameters
A vector of strings containing the list of
patient IDs to plot (a subset of those in the cma
object), or
NULL
for all
A number, the total duration (in days) of the whole
period to plot; in NA
it is automatically determined from the event
data such that the whole dataset fits.
Logical, should all patients be aligned (i.e., the actual dates are discarded and all plots are relative to the earliest date)?
A string, if "dates" show the actual dates at the
regular grid intervals, while for "days" (the default) shows the days since
the beginning; if align.all.patients == TRUE
, show.period
is
taken as "days".
The number of days at which the regular grid is drawn (or 0 for no grid).
Logical, should the legend be drawn?
The position of the legend on the x axis; can be "left", "right" (default), or a numeric value.
The position of the legend on the y axis; can be "bottom" (default), "top", or a numeric value.
A number between 0.0 and 1.0 specifying the opacity of the legend background.
numeric values specifying the cex of the various types of text.
A color or a function that specifies the single
colour or the colour palette used to plot the different medication; by
default rainbow
, but we recommend, whenever possible, a
colorblind-friendly palette such as viridis
or colorblind_pal
.
The style of the event (line style, width, and start and end symbols).
Logical, should the daily dose be printed as text?
Numeric, if daily dose is printed, what text size to use?
If NA
, don't print dose text with
outline, otherwise a color name/code for the outline.
Logical, print the daily dose centered on the segment or slightly below it?
Logical, should the daily dose be indicated through segment width?
Numeric, the segment width corresponding to the maximum daily dose (must be >= lwd.event but not too big either).
Logical, if TRUE
,
the line width of the even is scaled relative to all medication classes (i.e.,
relative to the global minimum and maximum doses), otherwise it is scale
relative only to its medication class.
The style of the "continuation" lines connecting consecutive events (colour, line style and width).
The colour used for missing event data.
Logical, should the follow-up window be plotted?
The follow-up window's colour.
Logical, should the observation window be plotted?
Attributes of the observation window (colour, shading density, angle and opacity).
Logical, should the plot use grayscale only (i.e., the
gray.colors
function)?
Logical, should the CMA values be printed?
Logical, should the CMA values be represented graphically?
A number, the proportion of the total horizontal plot space to be allocated to the CMA plot. Numeric, the minimum size of the plotting surface in characters; horizontally (min.plot.size.in.characters.horiz) referes to the the whole duration of the events to plot; vertically (min.plot.size.in.characters.vert) referes to a single event.
Numeric, the minimum size of the plotting surface in characters; horizontally (min.plot.size.in.characters.horiz) referes to the the whole duration of the events to plot; vertically (min.plot.size.in.characters.vert) referes to a single event.
Numeric, the maximum patients to attempt to plot.
The x-axis represents time (either in days since the earliest date or as actual dates), with consecutive events represented as ascending on the y-axis.
Each event is represented as a segment with style lty.event
and line
width lwd.event
starting with a pch.start.event
and ending with
a pch.end.event
character, coloured with a unique color as given by
col.cats
, extending from its start date until its end date.
Consecutive events are thus represented on consecutive levels of the y-axis
and are connected by a "continuation" line with col.continuation
colour, lty.continuation
style and lwd.continuation
width;
these continuation lines are purely visual guides helping to perceive the
sequence of events, and carry no information about the availability of
medication in this interval.
When several patients are displayed on the same plot, they are organized
vertically, and alternating bands (white and gray) help distinguish
consecutive patients.
Implicitly, all patients contained in the cma
object will be plotted,
but the patients.to.plot
parameter allows the selection of a subset
of patients.
# NOT RUN {
cma0 <- CMA0(data=med.events,
ID.colname="PATIENT_ID",
event.date.colname="DATE",
event.duration.colname="DURATION",
event.daily.dose.colname="PERDAY",
medication.class.colname="CATEGORY",
followup.window.start=0,
followup.window.start.unit="days",
followup.window.duration=2*365,
followup.window.duration.unit="days",
observation.window.start=30,
observation.window.start.unit="days",
observation.window.duration=365,
observation.window.duration.unit="days",
date.format="%m/%d/%Y",
summary="Base CMA");
plot(cma0, patients.to.plot=c("1","2"));
# }
Run the code above in your browser using DataLab