% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/guide-sec-axis-text.R
\name{guide_sec_axis_text}
\alias{guide_sec_axis_text}
\title{Guide optimised for secondary axis text annotations}
\usage{
guide_sec_axis_text(..., theme = theme_sec_axis_text())
}
\arguments{
\item{...}{Additional arguments passed to \code{\link[ggplot2:guide_axis]{ggplot2::guide_axis()}}, such as
\code{title}, \code{check.overlap}, or \code{angle}.}

\item{theme}{A \code{theme} object to style the guide. Defaults to
\code{\link[=theme_sec_axis_text]{theme_sec_axis_text()}}, which suppresses ticks and lines.}
}
\value{
A \code{guide} object to be used in a scale's \code{guide} argument or within
\code{\link[=sec_axis_text]{sec_axis_text()}}.
}
\description{
A wrapper around \code{\link[ggplot2:guide_axis]{ggplot2::guide_axis()}} that defaults to using
\code{\link[=theme_sec_axis_text]{theme_sec_axis_text()}}. This guide is designed to strip away standard axis
furniture (like lines and ticks) while preserving text, making it ideal for
secondary axes used as margin labels.
}
\examples{
library(ggplot2)
library(dplyr)

set_theme(
  ggrefine::theme_grey(
    panel_heights = rep(unit(50, "mm"), 100),
    panel_widths = rep(unit(75, "mm"), 100),
  )
)

mtcars |>
  ggplot(aes(x = wt, y = mpg, colour = as.factor(gear), fill = as.factor(gear))) +
  scale_colour_discrete(palette = blends::multiply(get_theme()$palette.colour.discrete)) +
  #clip = "off" is required for axis_text, axis_ticks and axis_bracket
  coord_cartesian(clip = "off") +
  #reference lines and shade
  ggscribe::reference_line(xintercept = 2.4) +
  ggscribe::reference_line(yintercept = 12)  +
  ggscribe::panel_shade(
    xmin = 4,
    xmax = 5,
  ) +
  #top axis
  scale_x_continuous(
    sec.axis = ggscribe::sec_axis_text(
      breaks = c(mean(c(4, 5))),
      labels = c("Range"),
      guide = ggscribe::guide_sec_axis_text(
        angle = 90,
      )
    )
  ) +
  ggscribe::axis_bracket(
    position = "top",
    breaks = c(4, 5),
  ) +
  ggscribe::axis_text(
    position = "top",
    breaks = c(2.4),
    labels = c("Threshold"),
  ) +
  #right axis
  ggscribe::axis_text(
    position = "right",
    breaks = 12,
    labels = "Threshold",
  ) +
  #'geom
  geom_point() +
  #annotations fit plot
  theme(plot.background = element_rect(colour = "grey92"))

}
\seealso{
\code{\link[=sec_axis_text]{sec_axis_text()}}, \code{\link[=theme_sec_axis_text]{theme_sec_axis_text()}}
}
