【发布时间】:2020-06-03 02:04:14
【问题描述】:
我有一张使用 ggplot 创建的地图。 x 和 y 轴上的文本是经度和纬度值。当我将数据框中的值添加到地图时,它们旁边有度数符号,但我想去掉度数符号。我只想要轴标题中的度数符号。我的地图是这样的。
下面是我用来导入地图和绘制数据的代码。我已经指定了这些度数符号的来源
canada = map_data("worldHires", "Canada")
ggplot(data = canada) +
geom_polygon(data = canada, aes(x=long, y = lat, group = group), fill = "grey") +
coord_sf(xlim=c(-64.5,-62.8), ylim=c(42.7,45), expand = FALSE) +
labs(x=expression(paste("Longitude ",degree,"W",sep="")),
y=expression(paste("Latitude ",degree,"N",sep=""))) +
#Here is where the degree symbols are added
geom_point(data = mapindividual_dets,
mapping = aes(x = longitude,
y = latitude),
size = 10)
这是我拥有的数据框示例,它给我带来了问题。我不能把它全部放在这里,因为它太大了。
mapindividual_dets = structure(list(location = c("ARB-04", "BIRCHY HEAD", "Boca1",
"BON-AR-S2", "BON-AR-S2", "BON-W-S5"), month = structure(c(12L,
10L, 10L, 8L, 11L, 2L), .Label = c("Jan", "Feb", "Mar", "Apr",
"May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"), class = c("ordered",
"factor")), year = c(2018, 2018, 2018, 2018, 2018, 2018), animal_id = c("NSTR-007",
"NSTR-007", "NSTR-021", "NSTR-007", "NSTR-007", "NSTR-007"),
detection_count = c(3L, 256L, 2L, 4L, 2L, 2L), num_unique_tags = c(1L,
1L, 1L, 1L, 1L, 1L), total_res_time_in_seconds = c(0, 1182040,
0, 2732221, 0, 0), latitude = c(24.94808, 44.5713, 26.32559,
-49.27732, -49.27732, -49.27985), longitude = c(-80.45412,
-64.03512, -80.07108, 69.48038, 69.48038, 69.47853)), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -6L), groups = structure(list(
location = c("ARB-04", "BIRCHY HEAD", "Boca1", "BON-AR-S2",
"BON-AR-S2", "BON-W-S5"), month = structure(c(12L, 10L, 10L,
8L, 11L, 2L), .Label = c("Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"), class = c("ordered",
"factor")), year = c(2018, 2018, 2018, 2018, 2018, 2018),
.rows = list(1L, 2L, 3L, 4L, 5L, 6L)), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE))
有人知道如何去掉坐标轴文本上的度数符号吗?
【问题讨论】: