last.plot.get.info | R Documentation |
Returns the full info the last adherence plot, to be used to modify and/or to add new elements to this plot.
last.plot.get.info()
This is intended for advanced users only.
It may return NULL
if no plotting was generated yet, but if one was, a
list contaning one named element for each type of plot produced (currently only
baseR and SVG are used).
For all types of plots there are a set of mapping functions useful for
transforming events in plotting coordinates: .map.event.x(x)
takes a
number of days x
, .map.event.date(d, adjust.for.earliest.date=TRUE)
takes a Date
d
(and implictely adjusts for the earilerst date
plotted), and .map.event.y(y)
takes a row ("event" number) y
.
Besides the shared elements (see the returned value), there are specific ones
as well.
For baseR, the members old.par and used.par contain the
original (pre-plot) par()
environment and the one used within
plot()
, respectively, in case these need restoring.
A list
(possibly empty) contaning one named element for each type
of plot produced (currently only baseR and SVG). Each may contain
shared and specific fields concerning:
the values of the parameters with which plot()
was invoked.
actual plot size and other characteristics.
actual title, axis names and labels and their position and size.
legend size, position and size and position of its components.
expanded cma$data
contaning, for each event, info about its
plotting, including the corresponding fullow-uo and observation windows,
event start and end, dose text (if any) and other graphical elements.
position, size of the partial CMAs (if any) and of their components.
position, size of the plotted CMAs (if any) and of their components.
rescaling function(s) useful for mapping events to plotting coordinates.
cma7 <- CMA7(data=med.events[med.events$PATIENT_ID %in% c(1,2),], 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(cma7); tmp <- last.plot.get.info(); names(tmp); tmp$baseR$legend$box; # legend position and size head(tmp$baseR$cma$data); # events + plotting info # Add a transparent blue rect between days 270 and 900: rect(tmp$baseR$.map.event.x(270), tmp$baseR$.map.event.y(1-0.5), tmp$baseR$.map.event.x(900), tmp$baseR$.map.event.y(nrow(tmp$baseR$cma$data)+0.5), col=adjustcolor("blue",alpha.f=0.5), border="blue"); # Add a transparent rect rect between dates 03/15/2036 and 03/15/2037: rect(tmp$baseR$.map.event.date(as.Date("03/15/2036", format="%m/%d/%Y")), tmp$baseR$.map.event.y(1-0.5), tmp$baseR$.map.event.date(as.Date("03/15/2037", format="%m/%d/%Y")), tmp$baseR$.map.event.y(nrow(tmp$baseR$cma$data)+0.5), col=adjustcolor("red",alpha.f=0.5), border="blue");
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.