如果我使用 来创建地图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))
Run Code Online (Sandbox Code Playgroud)
当我在网上看到示例时,它们通常看起来是正确的(例如下图,从这里复制),所以我猜这与我本地设置中的某些内容有关。
我曾尝试更改字体,使用library(extrafont)但这个问题仍然存在于我尝试的每种字体中。
我不认为这是一个特定ggplot-问题,因为我得到同样的事情与使用任何图形degree关键字plotmath。例如
par(mar=c(0,0,0,0))
plot.new()
text(0.5,0.5, bquote(120*degree*N), cex=5)
Run Code Online (Sandbox Code Playgroud)
我在Linux(Kubuntu 19.04), R3.5.2, ggplot2v. 3.2.1, sfv. 0.7-7。不确定还有哪些其他信息可能相关,但我可以用其他任何要求更新答案。
我有这段代码并且我正在使用 RStudio
library(tidyverse)
library(osmdata)
bbx <- getbb("hawaii")
border <- bbx %>%
opq() %>%
add_osm_feature(key = "place",
value = c("island")) %>%
osmdata_sf()
border
ggplot() +
geom_sf(
data = border$osm_lines,
inherit.aes = FALSE,
color = "black",
size = .4,
alpha = .8
)
Run Code Online (Sandbox Code Playgroud)
当我绘制这个时我有这个
正如您所看到的,我在标签中使用了一个白色矩形,而不是度数符号。
我怎么解决这个问题?
提前致谢
PS:我使用的是 Window11 64 位,RStudio 已更新为默认选项,并且所有软件包均已更新。