The theme_tq()
function creates a custom theme using tidyquant colors.
Usage
theme_tq(base_size = 11, base_family = "")
theme_tq_dark(base_size = 11, base_family = "")
theme_tq_green(base_size = 11, base_family = "")
Examples
# Load libraries
library(tidyquant)
library(dplyr)
library(ggplot2)
# Get stock prices
AAPL <- tq_get("AAPL", from = "2013-01-01", to = "2016-12-31")
# Plot using ggplot with theme_tq
AAPL %>% ggplot(aes(x = date, y = close)) +
geom_line() +
geom_bbands(aes(high = high, low = low, close = close),
ma_fun = EMA,
wilder = TRUE,
ratio = NULL,
n = 50) +
coord_x_date(xlim = c("2016-01-01", "2016-12-31"),
ylim = c(75, 125)) +
labs(title = "Apple BBands",
x = "Date",
y = "Price") +
theme_tq()
#> Warning: The following aesthetics were dropped during statistical transformation: high,
#> low, close, y
#> ℹ This can happen when ggplot fails to infer the correct grouping structure in
#> the data.
#> ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
#> variable into a factor?
#> Warning: The following aesthetics were dropped during statistical transformation: high,
#> low, close
#> ℹ This can happen when ggplot fails to infer the correct grouping structure in
#> the data.
#> ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
#> variable into a factor?