如何更改使用 sf 创建的地图中的经度默认标签?
How to change longitude default label in maps created with sf?
需要图书馆
library(ggplot2)
library(sf)
示例数据
nc <- st_read(system.file("shape/nc.shp", package="sf"))
默认数字
ggplot(data = nc) + geom_sf()
我想要同样的数字,但这次是法语。目前在图中用作标签的值的唯一问题是°W(西)应该是°O(西在法语中是Ouest)。我们该怎么做?
我查看了可以添加到图中的 coord_sf() 函数,但没有成功。
你可以定义一个处理轴的函数
makeLong <- function(x) paste0(-x, "\u00b0O") # \u00b0 is the Unicode degree symbol
现在你把这个函数传递给标签
ggplot(data = nc) + geom_sf() + scale_x_continuous(labels = makeLong)
需要图书馆
library(ggplot2)
library(sf)
示例数据
nc <- st_read(system.file("shape/nc.shp", package="sf"))
默认数字
ggplot(data = nc) + geom_sf()
我想要同样的数字,但这次是法语。目前在图中用作标签的值的唯一问题是°W(西)应该是°O(西在法语中是Ouest)。我们该怎么做?
我查看了可以添加到图中的 coord_sf() 函数,但没有成功。
你可以定义一个处理轴的函数
makeLong <- function(x) paste0(-x, "\u00b0O") # \u00b0 is the Unicode degree symbol
现在你把这个函数传递给标签
ggplot(data = nc) + geom_sf() + scale_x_continuous(labels = makeLong)