繁体   English   中英

ggplot2 图例标题不尊重 Google 字体的粗体

[英]ggplot2 legend title not respecting bold for Google Font

不知道为什么,但是当我使用 showtext::font_add_google 导入“Montserrat”字体时,图例标题不会是粗体:/

require(showtext);require(ggplot2)

font_add_google(name="Montserrat")
ggplot(mpg,aes(cty,hwy,fill=manufacturer))+geom_point()+
theme(text=element_text(family="Montserrat"),legend.title=element_text(face="bold"))

在此处输入图像描述

我认为这(部分)有效(尽管没有加粗),因为我在本地安装了蒙特塞拉特。 如果我尝试使用尚未安装的字体,即: font_add_google(name="Yesteryear")

我收到此错误并且没有 plot:

Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  : 
  polygon edge not found
In addition: Warning message:
In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  no font could be found for family "Yesteryear"

正如 Stefan 所指出的,在绘制作品之前添加showtext_auto() 它在 R Studio(在 Mac OS Catalina 下)中无法正确渲染,但在ggsave() 在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM