| ggstamp | R Documentation |
This function is used to stamp ggplot type plots with datetime and script name. User must provide the script name.
ggstamp(
plot,
file,
size,
script,
time,
model,
stamp.gg.style,
stamp.format = NULL,
stamp.funs = NULL
)
plot |
The plot to be stamped. |
file |
An optional output filename to be included in the stamp. |
size |
The size (list) for the plot, not the caption. Used to calculate the size of the caption. |
script |
the script name. Date and time will be added automatically. |
time |
The timestamp to be included. |
model |
An optional model name or object to be included in the stamp. |
stamp.gg.style |
A list of formatting options for the stamp text. For ggplot objects,
valid elements include size, colour, hjust, vjust, and other parameters accepted by
|
stamp.format |
A template for the stamp text using the
placeholders |
stamp.funs |
Optional named list of functions (elements |
The stamp text is generated by createStamp
based on stamp.format and stamp.funs. If the
plot already has a caption, the stamp is added below it.
How the stamp is added depends on size:
If size is given (always the case when called from
ggwrite), the stamp is drawn in a separate panel
underneath the plot (combined using patchwork). The
panel height is calculated from the number of stamp lines and
the font size, and the plot height is reduced accordingly so
the total size matches size. Placement of the stamp
(stamp.gg.style$position) and justification of its lines
(stamp.gg.style$hjust) are controlled independently.
If size is not given, the stamp is added as the plot
caption (labs(caption=...)) and styled using
theme(plot.caption=...). In this case, hjust
controls both placement and justification.
For gtable objects (e.g. from gridExtra::arrangeGrob), the
stamp is added at the bottom using arrangeGrob.
ggplot 2.2.1 or newer is required.
A stamped plot object. If size is given, a
patchwork object with the stamp panel underneath the plot.
Otherwise the plot with the stamp added as caption. For gtable
input, a gtable. If plot is a list, a list of stamped
plots.
Other Plotting:
canvasSize(),
ggwater(),
ggwrite()
library(ggplot2)
data(ChickWeight)
p1 <- ggplot(ChickWeight,aes(Time,weight,group=Chick,colour=factor(Diet)))+geom_line()
script <- "note"
ggstamp(p1,script)
## Or use ggwrite which will call ggstamp when the `script` argument is provided.
ggwrite(p1,script=script,canvas="wide")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.