ggtikz {ggtikz}R Documentation

Create a canvas and add a TikZ annotation.

Description

This is a helper function for quick one-step annotations. It creates a ggtikzCanvas from a ggplot, adds one annotation to it, and optionally draws the plot and the annotations.

Usage

ggtikz(gg_plot, ..., draw = TRUE)

Arguments

gg_plot

A ggplot object on which annotations should be made.

...

Passed to ggtikzAnnotation.

draw

TRUE or FALSE. Should gg_plot and the resulting annotation be drawn immediately? A tikz device needs to be open.

Details

For finer control, see ggtikzCanvas() and ggtikzAnnotation().

Value

A ggtikzCanvas object with one ggtikzAnnotation (specified in ...) already added. If draw = TRUE, the gg_plot and the annotations are drawn to the currently active device. This must be a tikzDevice, or an error will be raised.

See Also

ggtikzCanvas for creating a canvas which can store multiple annotations.

ggtikzAnnotation for creating an annotation, which can then be added to a canvas.

Examples

## Not run: 
library(ggplot2)
library(tikzDevice)
library(ggtikz)
p <- ggplot(mtcars, aes(disp, mpg)) + geom_point()
out <- tempfile(fileext = ".tikz")
tikz(out)
# Add a red circle in the middle of the plot.
ggtikz(p, "\\fill[red] (0.5,0.5) circle (2mm);", xy="plot")
dev.off()

## End(Not run)

[Package ggtikz version 0.1.3 Index]