% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ggplot2-markdown.R
\docType{data}
\name{geom_markdown}
\alias{geom_markdown}
\alias{GeomMarkdown}
\title{A ggplot2 geom for markdown labels}
\usage{
geom_markdown(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  fontsize = 11,
  math_font = "",
  lineheight = 1.2,
  max_width = 0,
  render_mode = c("typeface", "path"),
  justify = FALSE,
  style = NULL,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}}. If specified and
\code{inherit.aes = TRUE} (the default), it is combined with the default mapping
at the top level of the plot. You must supply \code{mapping} if there is no plot
mapping.}

\item{data}{The data to be displayed in this layer. There are three
options:

If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.

A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.

A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}

\item{stat}{The statistical transformation to use on the data for this layer.
When using a \verb{geom_*()} function to construct a layer, the \code{stat}
argument can be used to override the default coupling between geoms and
stats. The \code{stat} argument accepts the following:
\itemize{
\item A \code{Stat} ggproto subclass, for example \code{StatCount}.
\item A string naming the stat. To give the stat as a string, strip the
function name of the \code{stat_} prefix. For example, to use \code{stat_count()},
give the stat as \code{"count"}.
\item For more information and other ways to specify the stat, see the
\link[ggplot2:layer_stats]{layer stat} documentation.
}}

\item{position}{A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The \code{position} argument accepts the following:
\itemize{
\item The result of calling a position function, such as \code{position_jitter()}.
This method allows for passing extra arguments to the position.
\item A string naming the position adjustment. To give the position as a
string, strip the function name of the \code{position_} prefix. For example,
to use \code{position_jitter()}, give the position as \code{"jitter"}.
\item For more information and other ways to specify the position, see the
\link[ggplot2:layer_positions]{layer position} documentation.
}}

\item{...}{Other arguments passed to \code{\link[ggplot2]{layer}}.}

\item{fontsize}{Default font size in points. Overridden by the
\code{size} aesthetic if mapped.}

\item{math_font}{Name of the math font to use (e.g. \code{"stix"}).}

\item{lineheight}{Multi-line height multiplier (default 1.2), matching
\code{grid::gpar()} semantics.}

\item{max_width}{Maximum width in big points for automatic line
wrapping (default: 0, no wrapping).}

\item{render_mode}{\code{"typeface"} (default) or \code{"path"}; see
\code{\link{latex_grob}}.}

\item{justify}{Logical; justify wrapped lines. Requires
\code{max_width}. See \code{\link{latex_grob}}.}

\item{style}{A \code{\link{markdown_style}} object, CSS text, or the
path to a \code{.css} file, applied to every label this layer draws.
\code{NULL} falls back to
\code{\link{latex_options}(markdown_style = )}. Only the properties
that compile to LaTeX apply here --- a label has no block layout, so
margins and padding are ignored. See \code{\link{md_style}}.}

\item{na.rm}{If \code{FALSE}, the default, missing values are removed
with a warning. If \code{TRUE}, they are removed silently.}

\item{show.legend}{logical. Should this layer be included in the legends?
\code{NA}, the default, includes if any aesthetics are mapped.
\code{FALSE} never includes, and \code{TRUE} always includes.
It can also be a named logical vector to finely select the aesthetics to
display. To include legend keys for all levels, even
when no data exists, use \code{TRUE}.  If \code{NA}, all levels are shown in legend,
but unobserved levels are omitted.}

\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[ggplot2:annotation_borders]{annotation_borders()}}.}
}
\value{
A ggplot2 layer.
}
\description{
Renders markdown labels -- \code{**bold**}, \code{*italic*},
\code{`code`}, \code{~~strike~~} and \code{$math$} -- as native grid
grobs inside a plot. The markdown is converted to LaTeX and laid out by
MicroTeX, so the output is resolution-independent vector graphics.
}
\section{Aesthetics}{

\code{geom_markdown()} understands the following aesthetics (required
aesthetics are in bold):
\itemize{
\item \strong{\code{x}}
\item \strong{\code{y}}
\item \strong{\code{label}} --- markdown string
\item \code{size} --- font size in points (default: 11)
\item \code{colour} --- text colour (default: \code{"black"})
\item \code{angle} --- rotation angle in degrees (default: 0)
\item \code{hjust} --- horizontal justification, 0-1 (default: 0.5)
\item \code{vjust} --- vertical justification, 0-1 (default: 0.5)
\item \code{alpha} --- transparency (default: 1)
}
}

\examples{
\donttest{
if (requireNamespace("ggplot2", quietly = TRUE)) {
  library(ggplot2)
  df <- data.frame(
    x = 1:3, y = 1:3,
    lab = c("**bold**", "*slope* $\\\\beta_1$", "`code` and $x^2$")
  )
  ggplot(df, aes(x, y, label = lab)) + geom_markdown()
}
}
}
\seealso{
\code{\link{markdown_grob}}, \code{\link{geom_latex}}
}
\keyword{datasets}
