角度符号在地图轴标签中不正确 [英] degree symbol incorrect in map axis labels
问题描述
如果我使用 geom_sf
创建地图,则轴标签的度数符号错误.我得到的度数符号在文本中垂直居中,而不是像超级符号一样升起.
例如,
库(sf)库(ggplot2)nc = st_read(system.file("shape/nc.shp",package ="sf")))ggplot()+geom_sf(data = nc)+主题(axis.text = element_text(size = 16))
当我在网上看到示例时,它们通常看起来是正确的(例如,下图,复制自
我尝试使用 library(extrafont)
更改字体,但是这个问题仍然存在于我尝试过的每种字体中.
更新
我不认为这是特定于ggplot的问题,因为对于在 plotmath
中使用 degree
关键字的任何图形,我都会得到相同的结果.例如
par(mar = c(0,0,0,0))plot.new()文字(0.5,0.5,bquote(120 * degree * N),cex = 5)
我在 Linux
(Kubuntu 19.04), R
3.5.2, ggplot2
v.3.2.1, sf
v.0.7-7.不知道可能还有其他信息,但是我可以使用其他要求的信息来更新答案.
最终设法找到答案:
从X11开始,它说:
符号显示不正确的问题(例如quote(pi)和在具有以下功能的Linux系统上可以看到expression(10 ^ degree))安装了Wine Symbol字体–然后,fontconfig更喜欢此字体,并且误解了其编码.将以下行添加到〜/.fonts.conf"或"/etc/fonts/local.conf"可能会解决此问题首选URW Type 1符号字体.
< fontconfig>< match target ="pattern">< test name ="family">< string>符号</string></test>< edit name ="family" mode ="prepend" binding ="same">< string>标准符号L</string></edit></match></fontconfig>
将这些行添加到/etc/fonts/local.conf
中为我解决了这个问题.
If I create maps using geom_sf
, the axis labels have the wrong symbol for degrees. I get degree symbols that are vertically centred in the text, rather than raised like superscipts.
For example,
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))
When I see examples online, they typically look correct (e.g. image below, copied from here), so I guess it is related to something in my local setup.
I have tried changing font, using library(extrafont)
but this problem remains in every font I tried.
Update
I don't think this is a ggplot-specific issue, as I get the same thing with any graphics that uses the degree
keyword in plotmath
. For example
par(mar=c(0,0,0,0))
plot.new()
text(0.5,0.5, bquote(120*degree*N), cex=5)
I am on Linux
(Kubuntu 19.04), R
3.5.2, ggplot2
v. 3.2.1, sf
v. 0.7-7.
Not sure what other information might be relevant, but I can update answer with anything else that is requested.
Finally managed to track down the answer:
From ?X11 it says:
Problems with incorrect rendering of symbols (e.g., of quote(pi) and expression(10^degree)) have been seen on Linux systems which have the Wine symbol font installed – fontconfig then prefers this and misinterprets its encoding. Adding the following lines to ‘~/.fonts.conf’ or ‘/etc/fonts/local.conf’ may circumvent this problem by preferring the URW Type 1 symbol font.
<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>
Adding these lines to /etc/fonts/local.conf
solved the problem for me.
这篇关于角度符号在地图轴标签中不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!