% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ggInterval_tsplot.R
\name{ggInterval_lineplot}
\alias{ggInterval_lineplot}
\alias{ggInterval_tsplot}
\title{Interval-valued line plot}
\usage{
ggInterval_lineplot(data = NULL, mapping = aes(NULL),
barWidth = 0.5, add_line = TRUE)

ggInterval_tsplot(data = NULL, mapping = aes(NULL),
barWidth = 0.5, add_line = TRUE)
}
\arguments{
\item{data}{A ggInterval object. It can also be either RSDA object or
classical data frame, which will be automatically convert to ggInterval
data.}

\item{mapping}{Set of aesthetic mappings created by aes() or aes_().
Must include x for the ordered variable and y for the interval variable.
Optional aesthetics include group and fill for multiple line series.
It is the same as the mapping of ggplot2.}

\item{barWidth}{The width of the crossbar or errorbar indicating
the interval range at each x position. Default is 0.5.}

\item{add_line}{Logical; if TRUE (default), connect interval centers with a
line. Set FALSE when adding a customized line layer with
\code{geom_line(...)}.}
}
\value{
Return a ggplot2 object.
}
\description{
Visualize interval-valued data along an ordered horizontal
axis. A line can connect the centers of intervals at each position, with
crossbars or errorbars indicating the interval range. When the horizontal
axis is time, the display becomes an interval-valued time-series plot.
}
\examples{
\donttest{
if (requireNamespace("TTR", quietly = TRUE)) {
  data("ttrc", package = "TTR")
  stock.data <- subset(
    ttrc[, c("Date", "Close", "Low", "High")],
    format(Date, "\%Y-\%m") \%in\% c("1985-01", "1985-02", "1985-03")
  )
  stock.data$Month <- factor(
    month.abb[as.integer(format(stock.data$Date, "\%m"))],
    levels = month.abb[1:3]
  )
  stock.data$Day <- as.integer(format(stock.data$Date, "\%d"))
  stock.i <- classic2sym(
    stock.data,
    groupby = "customize",
    minData = stock.data$Low,
    maxData = stock.data$High
  )
  ggInterval_lineplot(stock.i, aes(y = V1, x = Day), barWidth = 0.6) +
    geom_point(aes(y = Close), shape = 21, fill = "#D95F02",
               color = "black", size = 1.6, stroke = 0.2) +
    coord_cartesian(xlim = c(1, 31), expand = FALSE) +
    facet_wrap(~Month, ncol = 1, scales = "free_y") +
    scale_x_continuous(breaks = c(1, 8, 15, 22, 29)) +
    labs(x = "Day of month", y = "Price") +
    ggthemes::theme_economist() +
    theme(strip.text = element_text(face = "bold"))
}
}
}
