% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api-plotting.R
\name{plot_data}
\alias{plot_data}
\title{Extract reusable data from an mfrmr plot object}
\usage{
plot_data(x, component = NULL, type = NULL, ...)
}
\arguments{
\item{x}{An \code{mfrm_plot_data} object, or a fitted/report/review object with a
\code{plot(..., draw = FALSE)} method.}

\item{component}{Optional single component name inside the reusable plot
data. When \code{NULL}, the full plot-data list is returned.}

\item{type}{Optional plot type passed to \code{plot()} when \code{x} is not already an
\code{mfrm_plot_data} object.}

\item{...}{Additional arguments passed to \code{plot(..., draw = FALSE)} when
\code{x} is not already an \code{mfrm_plot_data} object.}
}
\value{
The full reusable plot-data list, or the selected component.
}
\description{
\code{plot_data()} is a small accessor for users who want to build custom
base-R, ggplot2, plotly, or table-based displays from mfrmr plot helpers.
It accepts an existing \code{mfrm_plot_data} object, or any mfrmr object whose
\code{plot()} method supports \code{draw = FALSE}. Use \code{\link[=plot_data_components]{plot_data_components()}} first
when you want to inspect which components are available before extracting
one.
}
\examples{
\donttest{
toy <- load_mfrmr_data("example_core")
fit <- fit_mfrm(toy, "Person", c("Rater", "Criterion"), "Score", maxit = 30)

wright_plot_data <- plot_data(fit, type = "wright")
names(wright_plot_data)

wright_table <- plot_data(fit, type = "wright", component = "locations")
head(wright_table)

curves <- category_curves_report(fit, theta_points = 51)
curve_long <- plot_data(curves, component = "plot_long")
head(curve_long[, c("PlotType", "Theta", "Series", "Value")])

pathway_long <- plot_data(fit, type = "pathway", component = "pathway_long")
head(pathway_long[, c("Layer", "CurveGroup", "Theta", "Value")])
pathway_fit <- plot_data(fit, type = "pathway", component = "fit_measures")
head(pathway_fit[, c("Facet", "Level", "Infit", "Outfit", "FitStatus")])

info <- compute_information(fit, theta_points = 51)
sem_long <- plot_data(
  plot_information(info, type = "sem", draw = FALSE),
  component = "plot_long"
)
head(sem_long[, c("Metric", "Theta", "Value", "DisplayedByDefault")])
}
}
