Modifying fonts in ggplot2

前端 未结 7 1339
再見小時候
再見小時候 2020-11-29 16:43

I am looking for a way to modify font types in ggplot. At the moment I would be happy enough to simply change fonts to the \'courier\' font family, but ultimately my goal is

7条回答
  •  北海茫月
    2020-11-29 17:44

    Inspired by a post on kohske's blog I came up with this:

    theme_set( theme_bw( base_family= "serif"))
    
    theme_update( panel.grid.minor= theme_blank(),
                 panel.grid.major= theme_blank(),
                 panel.background= theme_blank(),
                 axis.title.x= theme_blank(),
                 axis.text.x= theme_text( family= "serif",
                   angle= 90, hjust= 1 ),
                 axis.text.x= theme_text( family= "serif"),
                 axis.title.y= theme_blank())
    
    theme_map <- theme_get()
    
    theme_set( theme_bw())
    

    Now when I want to use that particular theme:

    last_plot() + theme_map
    

    YMMV.

    BTW, if I had the power I would vote down the preferred answer:

    > grid.gedit("GRID.text",gp=gpar(fontfamily="mono"))
    Error in editDLfromGPath(gPath, specs, strict, grep, global, redraw) :
      'gPath' (GRID.text) not found
    

    Not sure what this means. Nor was I offered a link to comment on that answer; maybe something has changed on the site.

提交回复
热议问题