[英]degree symbol incorrect in ggplot map axis labels on Windows 10
[英]degree symbol incorrect in map axis labels
如果我使用geom_sf
创建地图,则轴标签的度数符号错误。 我得到的度数符号在文本中垂直居中,而不是像上标那样凸起。
例如,
library(sf)
library(ggplot2)
nc = st_read(system.file("shape/nc.shp", package="sf"))
ggplot() +
geom_sf(data = nc) +
theme(axis.text = element_text(size=16))
当我在网上看到示例时,它们通常看起来是正确的(例如下图,从此处复制),所以我猜它与我本地设置中的某些内容有关。
我尝试使用library(extrafont)
更改字体,但我尝试过的每种字体都存在这个问题。
我不认为这是一个特定于 ggplot 的问题,因为我对在plotmath
中使用degree
关键字的任何图形都得到了同样的结果。 例如
par(mar=c(0,0,0,0))
plot.new()
text(0.5,0.5, bquote(120*degree*N), cex=5)
我在Linux
(Kubuntu 19.04)、 R
ggplot2
v. 3.2.1、 sf
v. 0.7-7。 不确定还有哪些其他信息可能相关,但我可以根据要求更新答案。
最终设法找到答案:
从X11开始,它说:
在安装了Wine符号字体的Linux系统上,出现了符号(例如,quot(pi)和expression(10 ^ degree))的渲染不正确的问题,然后fontconfig偏爱了它,并误解了其编码。 在“〜/ .fonts.conf”或“ /etc/fonts/local.conf”中添加以下几行,可以通过使用URW Type 1符号字体来避免此问题。
<fontconfig>
<match target="pattern">
<test name="family"><string>Symbol</string></test>
<edit name="family" mode="prepend" binding="same">
<string>Standard Symbols L</string>
</edit>
</match>
</fontconfig>
将这些行添加到/etc/fonts/local.conf
为我解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.