概述:
我正在研究纬度如何影响落叶橡树的叶片衰老(叶片损失)。罗伯(Robur)。
我对在R中生成地图完全陌生,并且尝试了几天没有获得成功的预期结果。
如果有人可以提供帮助,我将非常感激。
问题:
我使用 my_map()制作了英国地图(参见图1),并且有一个名为 lonlat_df 的数据框,其中包含所有橡树的经度和纬度坐标记录树木。
我正在尝试使用 geom_point()将树数据点合并到英国地图上。但是,我不确定如何将地图,树种的GPS点以及关键参数对象整合在一起。
我的目标
要制作3张单独的英国地图,显示研究中记录的每种橡树树种的GPS点(请参见下面的期望输出),但我希望这些点为4种不同的颜色,以便与每个关键参数类别相关联(请参见下文),并为每个参数类别添加图例。
关键参数:
城市化指数:1 =城市,2 =郊区,3 =乡村,4 =农村
站密度指数::1 =站立,2 =几棵树以内或与其他树近距离,3 =站在10-30棵树之内,4 =大还是林地
物候指数::1 =不指示秋季时间,2 =第一次秋季着色,3 =部分秋季着色(> 25%的叶子),4 =高级秋季着色( > 75%的树叶)
R代码
##Import Packages
library(ggplot2)
library(maps)
library(mapdata)
library(tidyverse)
##Create objects for the key parameters from the data frame below called QuercusRobur1 to use as point data
latitude<-QuercusRobur1$Latitude
longitude<-QuercusRobur1$Longitude
PhenologyIndex<-QuercusRobur1$Phenological_Index
StandDensityIndex<-QuercusRobur1$Stand_density_index
UrbanisationIndex<-QuercusRobur1$Urbanisation_index
Species<-QuercusRobur1$Species
##Produce new data frame
lonlat_df<-as.data.frame(cbind(longitude, latitude, PhenologyIndex))
head(lonlat_df)
##Produce a map of the UK from maps:
UK <- map_data(map = "world", region = "UK")
head(UK)
dim(UK)
##Visualise the map of the UK using ggplot()
dev.new()
UK.Map<-ggplot(data = UK, aes(x = long, y = lat, group = group)) +
geom_point(colour="red", size=3, alpha=0.2)+
geom_polygon() +
coord_map()
##Produce Point Data
MapPoints<- MapUK + geom_point(data=lonlat_df, aes(x=long, y=lat, group=PhenologyIndex), colour="red", shape=21, fill="red", size=0.5)
图1
所需的输出:
我想在上面的R代码生成的英国地图上覆盖以下所需输出中显示的点的类型。
数据框
structure(list(Obs_.no = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 19L,
20L, 21L, 22L, 23L, 24L, 25L, 28L, 29L, 30L, 31L, 32L, 33L, 34L,
35L, 36L, 37L, 38L, 39L, 44L, 45L, 46L, 47L, 57L, 58L, 59L, 60L,
61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 74L,
75L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 93L,
102L, 103L, 104L, 112L, 113L, 114L, 115L, 116L, 117L, 118L, 119L,
120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 129L, 130L,
131L, 135L, 136L, 137L, 138L, 143L, 144L, 145L, 146L, 147L, 148L,
149L, 150L, 151L, 152L, 153L, 154L, 155L, 158L, 159L, 160L, 161L,
162L, 163L, 164L, 165L, 169L, 170L, 171L, 172L, 177L, 178L, 179L,
180L, 181L, 182L, 183L, 184L, 185L, 186L, 187L, 188L, 189L, 190L,
191L, 192L, 193L, 194L, 195L, 196L, 200L, 201L, 202L, 203L, 204L,
205L, 206L, 207L, 208L, 210L, 212L, 214L, 215L, 216L, 217L, 218L,
219L, 220L, 221L, 233L, 234L, 235L, 237L, 239L, 246L, 255L, 256L,
257L, 258L, 260L, 261L, 262L, 263L, 264L, 265L, 266L, 277L, 278L,
279L, 280L, 281L, 282L, 283L, 284L, 285L, 286L, 287L, 288L, 289L,
290L, 291L, 292L, 293L, 294L, 295L, 296L), Date_observed = structure(c(4L,
15L, 6L, 6L, 6L, 6L, 2L, 2L, 8L, 8L, 8L, 8L, 8L, 8L, 6L, 6L,
6L, 6L, 6L, 6L, 11L, 11L, 11L, 11L, 12L, 7L, 7L, 9L, 9L, 9L,
9L, 5L, 5L, 5L, 5L, 14L, 14L, 14L, 14L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 6L, 6L, 5L, 5L, 9L, 9L, 9L, 9L, 3L, 3L, 3L, 3L, 4L, 4L,
1L, 1L, 11L, 6L, 6L, 6L, 6L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 3L, 3L, 3L, 3L, 11L,
11L, 11L, 4L, 4L, 4L, 4L, 8L, 8L, 10L, 10L, 10L, 10L, 9L, 9L,
9L, 9L, 3L, 3L, 3L, 3L, 9L, 9L, 9L, 9L, 2L, 2L, 2L, 2L, 13L,
13L, 13L, 13L, 8L, 8L, 8L, 8L, 10L, 10L, 10L, 10L, 3L, 3L, 3L,
3L, 13L, 13L, 13L, 13L, 9L, 9L, 10L, 10L, 10L, 2L, 2L, 3L, 3L,
3L, 3L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 5L, 5L, 11L, 9L, 9L, 9L,
9L, 10L, 10L, 10L, 10L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 11L, 11L, 11L, 11L, 6L, 6L, 6L, 6L, 11L, 11L, 11L, 11L), .Label = c("10/1/18",
"10/19/18", "10/20/18", "10/21/18", "10/22/18", "10/23/18", "10/24/18",
"10/25/18", "10/26/18", "10/27/18", "10/28/18", "10/28/19", "10/29/18",
"12/9/18", "8/20/18"), class = "factor"), Latitude = c(51.4175,
52.12087, 52.0269, 52.0269, 52.0269, 52.0269, 52.947709, 52.947709,
51.491811, 51.491811, 52.59925, 52.59925, 52.59925, 52.59925,
51.60157, 51.60157, 52.6888, 52.6888, 52.6888, 52.6888, 50.697802,
50.697802, 50.697802, 50.697802, 53.62417, 50.446841, 50.446841,
53.959679, 53.959679, 53.959679, 53.959679, 51.78375, 51.78375,
51.78375, 51.78375, 51.456965, 51.456965, 51.456965, 51.456965,
51.3651, 51.3651, 51.3651, 51.3651, 52.01182, 52.01182, 52.01182,
52.01182, 50.114277, 50.114277, 51.43474, 51.43474, 51.10676,
51.10676, 51.10676, 51.10676, 50.435984, 50.435984, 50.435984,
50.435984, 51.78666, 51.78666, 52.441088, 52.441088, 52.552344,
49.259471, 49.259471, 49.259471, 49.259471, 50.461625, 50.461625,
50.461625, 50.461625, 51.746642, 51.746642, 51.746642, 51.746642,
52.2501, 52.2501, 52.2501, 52.2501, 52.423336, 52.423336, 52.423336,
52.423336, 53.615575, 53.615575, 53.615575, 53.615575, 51.08474,
51.08474, 51.08474, 53.19329, 53.19329, 53.19329, 53.19329, 55.96785,
55.96785, 56.52664, 56.52664, 56.52664, 56.52664, 51.8113, 51.8113,
51.8113, 51.8113, 52.580157, 52.580157, 52.580157, 52.580157,
50.52008, 50.52008, 50.52008, 50.52008, 51.48417, 51.48417, 51.48417,
51.48417, 54.58243, 54.58243, 54.58243, 54.58243, 52.58839, 52.58839,
52.58839, 52.58839, 52.717283, 52.717283, 52.717283, 52.717283,
50.740764, 50.740764, 50.740764, 50.740764, 52.57937, 52.57937,
52.57937, 52.57937, 50.736531, 50.736531, 50.79926, 50.79926,
50.79926, 53.675996, 53.675996, 48.35079, 48.35079, 48.35079,
48.35079, 51.36445, 51.36445, 51.36445, 51.36445, 52.122402,
52.122402, 52.122402, 52.16104, 52.16104, 55.91913, 51.6528,
51.6528, 51.6528, 51.6528, 51.88485, 51.88485, 51.88485, 51.88485,
52.34015, 52.34015, 52.34015, 52.026042, 52.026042, 52.026042,
52.026042, 51.319032, 51.319032, 51.319032, 51.319032, 51.51357,
51.51357, 51.51357, 51.51357, 53.43202, 53.43202, 53.43202, 53.43202,
51.50823, 51.50823, 51.50823, 51.50823), Longitude = c(-0.32118,
-0.29293, -0.7078, -0.7078, -0.7078, -0.7078, -1.435407, -1.435407,
-3.210324, -3.210324, 1.33011, 1.33011, 1.33011, 1.33011, -3.67111,
-3.67111, -3.30909, -3.30909, -3.30909, -3.30909, -2.11692, -2.11692,
-2.11692, -2.11692, -2.43155, -3.706923, -3.706923, -1.061008,
-1.061008, -1.061008, -1.061008, -0.65046, -0.65046, -0.65046,
-0.65046, -2.624917, -2.624917, -2.624917, -2.624917, 0.70706,
0.70706, 0.70706, 0.70706, -0.70082, -0.70082, -0.70082, -0.70082,
-5.541128, -5.541128, 0.45981, 0.45981, -2.32071, -2.32071, -2.32071,
-2.32071, -4.105617, -4.105617, -4.105617, -4.105617, -0.71433,
-0.71433, -0.176158, -0.176158, -1.337177, -123.107788, -123.107788,
-123.107788, -123.107788, 3.560973, 3.560973, 3.560973, 3.560973,
0.486416, 0.486416, 0.486416, 0.486416, -0.8825, -0.8825, -0.8825,
-0.8825, -1.787563, -1.787563, -1.787563, -1.787563, -2.432959,
-2.432959, -2.432959, -2.432959, -0.73645, -0.73645, -0.73645,
-0.63793, -0.63793, -0.63793, -0.63793, -3.18084, -3.18084, -3.40313,
-3.40313, -3.40313, -3.40313, -0.22894, -0.22894, -0.22894, -0.22894,
-1.948571, -1.948571, -1.948571, -1.948571, -4.20756, -4.20756,
-4.20756, -4.20756, -0.34854, -0.34854, -0.34854, -0.34854, -5.93229,
-5.93229, -5.93229, -5.93229, -1.96843, -1.96843, -1.96843, -1.96843,
-2.410575, -2.410575, -2.410575, -2.410575, -2.361234, -2.361234,
-2.361234, -2.361234, -1.89325, -1.89325, -1.89325, -1.89325,
-2.011143, -2.011143, -3.19446, -3.19446, -3.19446, -1.272824,
-1.272824, 10.91812, 10.91812, 10.91812, 10.91812, -0.23106,
-0.23106, -0.23106, -0.23106, -0.487443, -0.487443, -0.487443,
0.18702, 0.18702, -3.20987, -1.57361, -1.57361, -1.57361, -1.57361,
-0.17844, -0.17844, -0.17844, -0.17844, -1.27795, -1.27795, -1.27795,
-0.503114, -0.503114, -0.503114, -0.503114, -0.472994, -0.472994,
-0.472994, -0.472994, -3.18738, -3.18738, -3.18738, -3.18738,
-2.27968, -2.27968, -2.27968, -2.27968, -0.25847, -0.25847, -0.25847,
-0.25847), Altitude = c(5L, 0L, 68L, 68L, 68L, 68L, 104L, 104L,
15L, 15L, 23L, 23L, 23L, 23L, 184L, 184L, 176L, 176L, 176L, 176L,
12L, 12L, 12L, 12L, 178L, 36L, 36L, 11L, 11L, 11L, 11L, 210L,
210L, 210L, 210L, 97L, 97L, 97L, 97L, 23L, 23L, 23L, 23L, 0L,
0L, 0L, 0L, 9L, 9L, 4L, 4L, 200L, 200L, 200L, 200L, 160L, 160L,
160L, 160L, 166L, 166L, 0L, 0L, 0L, 47L, 47L, 47L, 47L, 58L,
58L, 58L, 58L, 43L, 43L, 43L, 43L, 97L, 97L, 97L, 97L, 133L,
133L, 133L, 133L, 123L, 123L, 123L, 123L, 128L, 128L, 128L, 15L,
15L, 15L, 15L, 14L, 14L, 65L, 65L, 65L, 65L, 129L, 129L, 129L,
129L, 140L, 140L, 140L, 140L, 18L, 18L, 18L, 18L, 30L, 30L, 30L,
30L, 19L, 19L, 19L, 19L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 96L,
96L, 96L, 96L, 169L, 169L, 169L, 169L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 43L, 43L, 43L, 75L, 75L,
109L, 110L, 110L, 110L, 110L, 95L, 95L, 95L, 95L, 112L, 112L,
112L, 0L, 0L, 0L, 0L, 24L, 24L, 24L, 24L, 38L, 38L, 38L, 38L,
29L, 29L, 29L, 29L, 20L, 20L, 20L, 20L), Species = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "Quercus robur", class = "factor"),
Tree_diameter = c(68.8, 10, 98.5, 97, 32.5, 45.1, 847, 817,
62, 71, 140, 111.4, 114.6, 167.1, 29, 40.1, 68, 45, 60, 54,
104, 122, 85, 71, 81, 39.8, 43.6, 20.1, 17.8, 15.6, 12.1,
81.8, 102.5, 75.5, 57.3, 0.3, 0.2, 0.3, 0.3, 70, 36, 53,
44, 31.5, 27.1, 23.3, 22, 69.4, 37.3, 19.9, 14.6, 196, 122,
118, 180, 58.6, 54.1, 58, 61.5, 58.4, 61, 134, 64, 52.2,
170, 114, 127, 158, 147.4, 135.3, 122.9, 104.1, 263, 237,
322, 302, 175, 182, 141, 155, 89, 41, 70, 83, 141, 86.5,
82, 114.5, 129, 127, 143, 125, 92, 68, 90, 24.5, 20.1, 63.7,
39.8, 66.2, 112.4, 124.5, 94.1, 68.6, 74.4, 23.6, 27.7, 22.9,
25.2, 24.2, 54.7, 43, 33.1, 306, 274, 56, 60, 72.5, 128.5,
22, 16, 143, 103, 53, 130, 48.4, 69.8, 6.4, 18.6, 129.2,
41.7, 57.6, 14, 41.7, 30.2, 39.5, 24.2, 320, 352, 120.9,
108.3, 53.2, 274, 85, 52, 43, 38, 37, 219, 215, 216, 175,
85.9, 49.7, 97.1, 40.8, 62.4, 80.3, 43, 50.3, 28.7, 31.9,
181.5, 149.7, 122, 143.6, 148, 145, 99, 28, 32, 54, 54, 169,
152, 160, 138, 90.8, 87.9, 77.4, 81.2, 91.7, 62.7, 50, 72.9,
23.7, 58, 80.7, 73.7), Urbanisation_index = structure(c(2L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L,
4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 2L, 2L, 2L,
2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 4L, 4L,
4L, 4L, 4L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
4L, 4L, 4L, 4L, 1L, 1L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 2L, 2L, 2L,
2L, 4L, 4L, 2L, 2L, 2L, 3L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 4L, 4L, 1L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L,
4L, 4L, 4L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L), .Label = c("1", "2", "3",
"4"), class = "factor"), Stand_density_index = structure(c(3L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 4L, 1L, 1L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 2L, 2L, 4L, 4L, 3L, 3L, 3L, 3L, 4L, 3L,
4L, 4L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L,
2L, 2L, 2L, 2L, 2L, 3L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 1L, 1L, 2L,
1L, 1L, 1L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 2L,
3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L), .Label = c("1", "2", "3",
"4"), class = "factor"), Canopy_Index = c(85L, 85L, 85L,
75L, 45L, 25L, 75L, 65L, 75L, 75L, 95L, 95L, 95L, 95L, 95L,
65L, 85L, 65L, 95L, 85L, 85L, 85L, 75L, 75L, 65L, 85L, 85L,
75L, 75L, 85L, 65L, 95L, 85L, 95L, 95L, 75L, 75L, 85L, 85L,
85L, 85L, 85L, 75L, 85L, 85L, 85L, 85L, 75L, 75L, 85L, 85L,
65L, 75L, 85L, 75L, 95L, 95L, 95L, 95L, 75L, 65L, 95L, 95L,
55L, 75L, 65L, 75L, 65L, 85L, 95L, 95L, 75L, 95L, 75L, 95L,
65L, 75L, 75L, 85L, 85L, 65L, 95L, 65L, 65L, 65L, 65L, 65L,
65L, 85L, 85L, 75L, 95L, 85L, 85L, 75L, 45L, 55L, 35L, 35L,
25L, 25L, 95L, 85L, 75L, 85L, 85L, 75L, 75L, 65L, 75L, 85L,
65L, 45L, 95L, 95L, 95L, 95L, 65L, 75L, 45L, 35L, 75L, 95L,
95L, 85L, 75L, 65L, 85L, 95L, 75L, 85L, 85L, 95L, 65L, 65L,
45L, 65L, 85L, 35L, 95L, 85L, 85L, 85L, 85L, 75L, 65L, 65L,
65L, 65L, 55L, 75L, 85L, 85L, 95L, 85L, 75L, 75L, 85L, 65L,
45L, 75L, 75L, 65L, 65L, 75L, 65L, 95L, 95L, 95L, 85L, 65L,
75L, 75L, 75L, 65L, 75L, 35L, 75L, 75L, 75L, 75L, 25L, 45L,
45L, 35L, 85L, 95L, 85L, 95L), Phenological_Index = c(2L,
4L, 2L, 2L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L,
2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
4L, 4L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 4L, 1L, 1L, 1L, 1L, 3L, 2L, 3L, 3L,
3L, 3L, 4L, 3L, 2L, 3L, 2L, 2L, 2L, 1L, 3L, 1L, 4L, 2L, 4L,
3L, 3L, 3L, 2L, 2L, 2L, 1L, 2L, 3L, 3L, 2L, 3L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 4L, 3L, 3L, 3L, 2L, 3L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L)), row.names = c(NA, -189L
), class = "data.frame")
答案 0 :(得分:1)
不需要创建额外的数据框,尤其是在其中不包含关键参数变量的情况下。
您可以尝试以下方法:
p <- ggplot(QuercusRobur1,
aes(x = Longitude, y = Latitude)) +
geom_polygon(data = UK,
aes(x = long, y = lat, group = group),
inherit.aes = FALSE) +
geom_point() +
coord_map(xlim = c(-10, 5)) + #limits added as there are some points really far away
theme_classic()
p +
aes(color = Urbanisation_index) +
scale_color_discrete(name = "Urbanisation Index",
labels = c("Urban", "Suburban", "Village", "Rural"))
p +
aes(color = Stand_density_index) +
scale_color_discrete(name = "Stand Density Index",
labels = c("Standing alone",
"Within a few trees or close proximity to other trees",
"Within a stand of 10-30 trees",
"Large or woodland"))
p +
aes(color = factor(Phenological_Index)) +
scale_color_discrete(name = "Phenological Index",
labels = c("No indication of autumn timing",
"First autumn tinting",
"Partial autumn tinting (>25% of leaves)",
"Advanced autumn tinting (>75% of leaves)"))