我有以下代码片段。
library(highcharter)
Year <- 2001:2020
X <- rnorm(20)
Y <- rnorm(20)
dataf <- data.frame(Year, X, Y)
highcharter::highchart() |>
hc_add_series(name = "Hessen",
data = dataf$X,
color = "green",
type = "column") |>
hc_add_series(name = "Deutschland",
data = dataf$Y,
color = "blue",
type = "column") |>
hc_xAxis(type = "datetime",
labels = list(format = "%Y")) |>
hc_yAxis(title = list(text = "X and Y",
color = "black"))
我有两个问题:
试试这个:
highcharter::highchart() |>
hc_add_series(name = "Hessen",
data = dataf$X,
color = "green",
type = "column") |>
hc_add_series(name = "Deutschland",
data = dataf$Y,
color = "blue",
type = "column") |>
hc_xAxis(categories = dataf$Year) |> # Here!
hc_yAxis(title = list(text = "X and Y",
color = "black"))