2020-04-04 19:11:10 +02:00
|
|
|
library(apexcharter)
|
|
|
|
data("economics_long", package = "ggplot2")
|
|
|
|
|
|
|
|
eco <- economics_long %>%
|
2021-01-15 10:53:51 +01:00
|
|
|
subset(variable %in% c("pce", "pop")) %>%
|
|
|
|
transform(value = round(value))
|
2020-04-04 19:11:10 +02:00
|
|
|
|
|
|
|
# add second y-axis
|
|
|
|
apex(eco, aes(x = date, y = value, color = variable), type = "line") %>%
|
|
|
|
ax_yaxis(title = list(text = "Pce")) %>%
|
|
|
|
ax_yaxis2(opposite = TRUE, title = list(text = "Pop"))
|
|
|
|
|
|
|
|
# Customize axis a bit more
|
|
|
|
apex(eco, aes(x = date, y = value, color = variable), type = "line") %>%
|
|
|
|
ax_yaxis(
|
|
|
|
title = list(text = "Pce"),
|
|
|
|
axisBorder = list(
|
|
|
|
show = TRUE,
|
|
|
|
color = "#008FFB"
|
|
|
|
),
|
|
|
|
labels = list(
|
|
|
|
style = list(
|
|
|
|
colors = "#008FFB"
|
|
|
|
)
|
|
|
|
),
|
|
|
|
tooltip = list(
|
|
|
|
enabled = TRUE
|
|
|
|
)
|
|
|
|
) %>%
|
|
|
|
ax_yaxis2(
|
|
|
|
opposite = TRUE,
|
|
|
|
min = 160000,
|
|
|
|
forceNiceScale = TRUE,
|
|
|
|
title = list(text = "Pop"),
|
|
|
|
axisBorder = list(
|
|
|
|
show = TRUE,
|
|
|
|
color = "#00E396"
|
|
|
|
),
|
|
|
|
labels = list(
|
|
|
|
style = list(
|
|
|
|
colors = "#00E396"
|
|
|
|
)
|
|
|
|
),
|
|
|
|
tooltip = list(
|
|
|
|
enabled = TRUE
|
|
|
|
)
|
|
|
|
)
|