% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/UserFacingCoreFunctions.R
\name{ggplotplus_to_patchwork}
\alias{ggplotplus_to_patchwork}
\title{Convert a ggplotplus plot into a patchwork-compatible element}
\usage{
ggplotplus_to_patchwork(plot)
}
\arguments{
\item{plot}{A ggplot or ggplotplus plot object.}
}
\value{
A patchwork-compatible wrapped plot element.
}
\description{
Convenience helper for converting ggplotplus plot objects into
patchwork-compatible wrapped elements.
}
\details{
This helper is primarily intended for compatibility with \pkg{patchwork},
whose plot-composition operators may not yet fully recognize custom S7
plot subclasses under ggplot2 4.x.

Internally, the plot is first converted into a grob using
\code{ggplotplus_to_cowplot()}, then wrapped using
\code{patchwork::wrap_elements()}.

This helper requires the \pkg{patchwork} package, but ggplotplus does not
import patchwork. Users only need patchwork installed if they want to compose
ggplotplus plots with patchwork.
}
\examples{
if(requireNamespace("patchwork", quietly = TRUE)) {

p1 = ggplot2::ggplot(iris, ggplot2::aes(Sepal.Length, Petal.Length, colour = Species)) +
  geom_point_plus()

p2 = ggplot2::ggplot(mtcars, ggplot2::aes(wt, mpg, shape = factor(cyl))) +
  geom_point_plus()

(ggplotplus_to_patchwork(p1) |
  ggplotplus_to_patchwork(p2)) +
  patchwork::plot_annotation(
    title = "ggplotplus + patchwork"
  )
}
}
