我正在尝试在 R 中为 highcharter 设置样式,在 x 轴上使用分组标签。
如何为标签周围的框边框着色?
代码:
mpgg <- mpg %>%
filter(!manufacturer %in% c("volkswagen", "chevrolet")) %>%
filter(class %in% c("compact", "midsize", "subcompact")) %>%
group_by(class, manufacturer) %>%
summarize(count = n()) %>%
ungroup()
categories_grouped <- x %>%
select(class, manufacturer) %>%
group_by(name = class) %>%
summarise(categories = list(manufacturer)) %>%
list_parse()
hchart(
mpgg,
"column",
name = "Cars",
hcaes(y = count)
) %>%
hc_xAxis(categories = categories_grouped,
labels = list(style = list(fontSize = "10px"))
) %>%
hc_add_dependency("plugins/grouped-categories.js")
答案 0 :(得分:2)
您可以通过轴的 tickColor
设置框的边框颜色:
library(highcharter)
library(ggplot2)
library(dplyr)
mpgg <- mpg %>%
filter(!manufacturer %in% c("volkswagen", "chevrolet")) %>%
filter(class %in% c("compact", "midsize", "subcompact")) %>%
group_by(class, manufacturer) %>%
summarize(count = n()) %>%
ungroup()
#> `summarise()` has grouped output by 'class'. You can override using the `.groups` argument.
categories_grouped <- mpgg %>%
select(class, manufacturer) %>%
group_by(name = class) %>%
summarise(categories = list(manufacturer)) %>%
list_parse()
hchart(
mpgg,
"column",
name = "Cars",
hcaes(y = count)
) %>%
hc_xAxis(categories = categories_grouped,
labels = list(style = list(fontSize = "10px")),
tickColor = '#FF0000'
) %>%
hc_add_dependency("plugins/grouped-categories.js")