Is there a way to avoid the increasing indention of the y axis label with each successive graph?
library(xts)
library(highcharter)
dates = seq(as.Date("2012-01-01"), as.Date("2012-01-04"), by="day")
x1 = xts(c(2,3,1,5), dates)
x2 = xts(c(1,1.5,2,1), dates)
highchart(type = "stock") %>%
hc_yAxis_multiples(
list(top = "0%", height = "60%", title = list(text = "Var1")),
list(top = "60%", height = "40%", title = list(text = "Var2"))) %>%
hc_add_series(x1, yAxis=0, compare="percent", color="blue") %>%
hc_add_series(x2, yAxis=1, color="black")
The graph created is:
This can be fixed by manually setting offset
of the second y-axis. From the API reference:
offset: number
The distance in pixels from the plot area to the axis line. A positive offset moves the axis with it's line, labels and ticks away from the plot area. This is typically used when two or more axes are displayed on the same side of the plot. With multiple axes the offset is dynamically adjusted to avoid collision, this can be overridden by setting offset explicitly.
Defaults to 0.
highchart(type = "stock") %>%
hc_yAxis_multiples(
list(top = "0%", height = "60%", title = list(text = "Var1")),
list(top = "60%", height = "40%", offset = 0, title = list(text = "Var2"))) %>%
hc_add_series(x1, yAxis=0, compare="percent", color="blue") %>%
hc_add_series(x2, yAxis=1, color="black")