% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ms_chart.R
\name{ms_chart_combine}
\alias{ms_chart_combine}
\title{Combined chart object}
\usage{
ms_chart_combine(..., secondary_y = NULL, secondary_x = NULL)
}
\arguments{
\item{...}{named \code{ms_chart} objects.}

\item{secondary_y}{character vector of chart names to plot on
the secondary (right) y-axis.}

\item{secondary_x}{character vector of chart names to plot on
the secondary (top) x-axis.}
}
\description{
Combine several chart objects into a single chart
with shared axes. Each chart must be a named argument.

The title and x-axis label are taken from the first chart.
The y-axis label of the first chart on the secondary axis is
used as the secondary y-axis label.

Only one secondary y-axis (right) and one secondary x-axis (top)
are supported.
}
\examples{
# example chart 01 -------

dat <- longley
dat$Year <- as.Date(paste0(dat$Year, "-01-01"))

dat_empl <- data.frame(
  Year = rep(dat$Year, 2),
  value = c(dat$Employed, dat$Unemployed),
  serie = rep(c("Employed", "Unemployed"), each = nrow(dat)),
  stringsAsFactors = FALSE
)

empl <- ms_barchart(
  data = dat_empl, x = "Year",
  y = "value", group = "serie"
)
empl <- chart_labels(
  x = empl, title = "Longley's Economic Regression Data",
  xlab = "1947 to 1962", ylab = "Employment"
)
empl <- chart_ax_x(x = empl, num_fmt = "yyyy")
empl <- as_bar_stack(x = empl, dir = "vertical")

gdp <- ms_linechart(data = dat, x = "Year", y = "GNP.deflator")
gdp <- chart_labels(x = gdp, ylab = "GNP implicit price deflator (1954 = 100)")

cb <- ms_chart_combine(empl = empl, gdp = gdp, secondary_y = "gdp")
}
\seealso{
\code{\link[=chart_settings]{chart_settings()}}, \code{\link[=chart_ax_x]{chart_ax_x()}}, \code{\link[=chart_ax_y]{chart_ax_y()}},
\code{\link[=chart_data_labels]{chart_data_labels()}}, \code{\link[=chart_theme]{chart_theme()}}, \code{\link[=chart_labels]{chart_labels()}}

Other 'Office' chart objects: 
\code{\link{ms_areachart}()},
\code{\link{ms_barchart}()},
\code{\link{ms_bubblechart}()},
\code{\link{ms_linechart}()},
\code{\link{ms_piechart}()},
\code{\link{ms_radarchart}()},
\code{\link{ms_scatterchart}()},
\code{\link{ms_stockchart}()}
}
\concept{'Office' chart objects}
