【问题标题】:Set the font in highcharter R plot在 highcharter R 图中设置字体
【发布时间】:2020-02-14 08:30:26
【问题描述】:

有没有办法在 R 中更改高图的默认字体?

library("highcharter")
data(diamonds, mpg, package = "ggplot2")

hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class))

【问题讨论】:

    标签: r r-highcharter


    【解决方案1】:

    直接抄自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)
    

    【讨论】:

    • 是否也可以选择坐标轴的字体大小和颜色?
    • 你基本上可以编辑任何东西,你只需要看看手册......
    • 我很确定您可以使用关键字 highcharter 和 manual 使用 google
    【解决方案2】:

    如果要更改图表上所有文字的主题:

    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)
    

    【讨论】:

      猜你喜欢
      • 2020-01-19
      • 1970-01-01
      • 1970-01-01
      • 2019-05-26
      • 1970-01-01
      • 2020-03-27
      • 2020-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多