R - Highcharter,如何避免增加 y 轴标签的缩进?
R - Highcharter, How to avoid increasing the indentation of the y axis label?
有没有办法避免每个连续图形的 y 轴标签 增加缩进?
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")
创建的图表是:
这可以通过手动设置第二个 y 轴的 offset
来解决。来自 API 参考:
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")
有没有办法避免每个连续图形的 y 轴标签 增加缩进?
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")
创建的图表是:
这可以通过手动设置第二个 y 轴的 offset
来解决。来自 API 参考:
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")