% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sol.chart.R
\name{sol.chart}
\alias{sol.chart}
\title{Draw a chart from a sol.df table}
\usage{
sol.chart(
  x,
  conditions = NULL,
  solution_types = c("conservative", "intermediate", "parsimonious"),
  model = NULL,
  intermediate_branch = NULL,
  colors = c(conservative = "#222222", intermediate = "#E69F00", parsimonious =
    "#0072B2"),
  show_cases = TRUE,
  show_pi_fit = TRUE,
  show_solution_fit = TRUE,
  digits = 2,
  title = NULL,
  note = TRUE,
  legend = FALSE,
  point_size = 3.2,
  text_size = 3.3,
  theme = .plot_theme()
)
}
\arguments{
\item{x}{A data frame returned by \code{\link[=sol.df]{sol.df()}}.}

\item{conditions}{Optional character vector giving the condition order. If
\code{NULL}, conditions are inferred from \code{Prime_Implicants} in order of first
appearance.}

\item{solution_types}{Solution types to display, in plotting order. Accepted
values follow the common qcaERT solution-type conventions, excluding \code{"all"}.
\code{"complex"} is accepted as an alias for \code{"conservative"} for display use.}

\item{model}{Optional positive integer selecting which model to display when
\code{x} contains more than one model.}

\item{intermediate_branch}{Optional intermediate branch to display when \code{x}
contains more than one intermediate branch.}

\item{colors}{Named character vector with colors for \code{"conservative"},
\code{"intermediate"}, and \code{"parsimonious"}.}

\item{show_cases}{Logical; if \code{TRUE}, include a cases row. Cases are taken
from the most detailed available configuration in each column.}

\item{show_pi_fit}{Logical; if \code{TRUE}, include prime-implicant consistency,
raw coverage, unique coverage, and PRI rows.}

\item{show_solution_fit}{Logical; if \code{TRUE}, include solution-level
consistency, coverage, and PRI rows.}

\item{digits}{Non-negative integer used to format fit statistics.}

\item{title}{Optional plot title. If \code{NULL}, a default title is used.}

\item{note}{Logical; if \code{TRUE}, include a caption explaining symbols and
colors.}

\item{legend}{Logical; if \code{TRUE}, include ggplot legends for solution type
and condition state.}

\item{point_size}{Size of presence/absence symbols.}

\item{text_size}{Size of table text.}

\item{theme}{A ggplot2 theme object added to the chart.}
}
\value{
A ggplot object.
}
\description{
Turns the solution table returned by \code{\link[=sol.df]{sol.df()}} into a visual chart
of sufficient configurations. The chart uses one column per aligned prime
implicant and shows condition presence, condition absence, prime implicant
fit, solution fit, and optionally cases.
}
\details{
\code{sol.chart()} is a visual display for \code{\link[=sol.df]{sol.df()}} tables. It does not extract
solutions from QCA minimization objects. Use \code{\link[=sol.df]{sol.df()}} first, then pass the
resulting table to \code{sol.chart()}.

Prime implicant columns are aligned according to the following hierarchy:
conservative/complex, intermediate, and parsimonious. When several
detailed configurations simplify into the same intermediate or parsimonious
prime implicant, the simpler prime implicant is repeated across the relevant
columns so that the detailed empirical configurations remain visible.

Filled circles denote condition presence. Open circles denote condition
absence. Empty cells denote conditions that are irrelevant to that prime
implicant at the displayed solution type.
}
\examples{
library(QCA)
data(LC)

conditions <- c("DEV", "URB", "LIT", "IND", "STB")
dir_exp <- rep("1", length(conditions))

tt <- truthTable(
  data = LC,
  outcome = "SURV",
  conditions = conditions,
  incl.cut = 0.8,
  n.cut = 1
)

enhanced <- findRows(tt, type = 2)

con <- minimize(
  input = tt,
  include = "",
  details = TRUE,
  show.cases = FALSE
)

par <- minimize(
  input = tt,
  include = "?",
  exclude = enhanced,
  details = TRUE,
  show.cases = FALSE
)

int <- minimize(
  input = tt,
  include = "?",
  dir.exp = dir_exp,
  exclude = enhanced,
  details = TRUE,
  show.cases = FALSE
)

solution_table <- sol.df(
  conservative = con,
  parsimonious = par,
  intermediate = int,
  solution = "all",
  which_M = 1,
  i_mode = "C1P1",
  include_cases = FALSE,
  digits = 2
)

if (requireNamespace("ggplot2", quietly = TRUE)) {
  library(ggplot2)

  sol.chart(
    solution_table,
    conditions = conditions,
    solution_types = c("conservative", "intermediate", "parsimonious"),
    show_cases = FALSE
  )
}

\donttest{
library(QCA)
library(ggplot2)
data(LR)

conditions <- c("DEV", "URB", "LIT", "IND", "STB")
outcome <- "SURV"
dir_exp <- rep("1", length(conditions))

thresholds <- list(
  DEV = findTh(LR$DEV, groups = 7),
  URB = findTh(LR$URB, groups = 4),
  LIT = findTh(LR$LIT, groups = 4),
  IND = findTh(LR$IND, groups = 4),
  STB = findTh(LR$STB, groups = 4),
  SURV = findTh(LR$SURV, groups = 4)
)

dat <- LR
dat$DEV <- calibrate(LR$DEV, type = "fuzzy", thresholds = thresholds$DEV)
dat$URB <- calibrate(LR$URB, type = "fuzzy", thresholds = thresholds$URB)
dat$LIT <- calibrate(LR$LIT, type = "fuzzy", thresholds = thresholds$LIT)
dat$IND <- calibrate(LR$IND, type = "fuzzy", thresholds = thresholds$IND)
dat$STB <- calibrate(LR$STB, type = "fuzzy", thresholds = thresholds$STB)
dat$SURV <- calibrate(LR$SURV, type = "fuzzy", thresholds = thresholds$SURV)

tt <- truthTable(
  data = dat,
  outcome = outcome,
  conditions = conditions,
  incl.cut = 0.8,
  n.cut = 1,
  complete = TRUE,
  show.cases = TRUE
)
enhanced <- findRows(tt, type = 2)

con <- minimize(tt, include = "", details = TRUE, show.cases = FALSE)
par <- minimize(tt, include = "?", exclude = enhanced, details = TRUE, show.cases = FALSE)
int <- minimize(
  tt,
  include = "?",
  dir.exp = dir_exp,
  exclude = enhanced,
  details = TRUE,
  show.cases = FALSE
)

solution_table <- sol.df(
  conservative = con,
  intermediate = int,
  parsimonious = par,
  solution = "all",
  which_M = 1,
  i_mode = "C1P1",
  include_cases = TRUE,
  digits = 2
)

sol.chart(solution_table)
}

}
\seealso{
\code{\link[=sol.df]{sol.df()}}, \link{qcaERT_plots}
}
