在 highcharter R plot 中设置字体
Set the font in highcharter R plot
有没有办法更改 R 中 highcharter plot 的默认字体?
library("highcharter")
data(diamonds, mpg, package = "ggplot2")
hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class))
直接抄自highcharter手册:
thm <- hc_theme(colors = c('red','green','blue'),
chart = list(backgroundColor = "#15C0DE"),
title = list(style = list(color ='#333333',
fontFamily = "Erica One")),
subtitle = list(style = list(color ='#666666',
fontFamily = "Shadows Into Light")),
legend = list(itemStyle = list(fontFamily ='Tangerine',color ='black')
,itemHoverStyle = list(color ='gray')))
hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class)) %>%
hc_add_theme(thm)
如果要更改图表上所有文字的主题:
my_theme <- hc_theme(
chart = list(
backgroundColor = "#f4fcfe",
style = list(
fontFamily = "Montserrat"
)
)
)
hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class)) %>%
hc_add_theme(my_theme)
有没有办法更改 R 中 highcharter plot 的默认字体?
library("highcharter")
data(diamonds, mpg, package = "ggplot2")
hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class))
直接抄自highcharter手册:
thm <- hc_theme(colors = c('red','green','blue'),
chart = list(backgroundColor = "#15C0DE"),
title = list(style = list(color ='#333333',
fontFamily = "Erica One")),
subtitle = list(style = list(color ='#666666',
fontFamily = "Shadows Into Light")),
legend = list(itemStyle = list(fontFamily ='Tangerine',color ='black')
,itemHoverStyle = list(color ='gray')))
hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class)) %>%
hc_add_theme(thm)
如果要更改图表上所有文字的主题:
my_theme <- hc_theme(
chart = list(
backgroundColor = "#f4fcfe",
style = list(
fontFamily = "Montserrat"
)
)
)
hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class)) %>%
hc_add_theme(my_theme)