在 ggplot 中手动调整颜色 (geom_bar)
Manually adjusting colors in ggplot (geom_bar)
我想(手动)改变条形图的颜色。现在,我使用 fill=group
来确定配色方案。但是,我不喜欢亮粉色,想手动改成紫色,其他颜色都可以。如何在不改变图表其余部分的情况下更改颜色?
我在条形图中使用了以下命令:
ggplot(Dispersion3, aes(Batch.location, Number, fill=group))+
geom_bar(stat='identity')+
scale_x_discrete(guide = guide_axis(angle = 45))+
facet_grid(~factor(Season, levels=c("Winter1", "Spawn1", "Forage", "Winter2", "Spawn2"), labels = c("Winter-19/20", "Spawn-20", "Forage-20", "Winter-20/21", "Spawn-21")))+
scale_fill_discrete(name = "Distance from batch", labels = c("> 40 km", "30 - 40 km", "20 - 30 km", "10 - 20 km", "5 - 10 km", "< 5 km"))
[![在此处输入图片描述][1]][1]
数据=色散3
structure(list(Transmitter = c("A69-1602-54311", "A69-1602-54311",
"A69-1602-54312", "A69-1602-54312", "A69-1602-54313", "A69-1602-54313",
"A69-1602-54314", "A69-1602-54314", "A69-1602-54315", "A69-1602-54315",
"A69-1602-54316", "A69-1602-54316", "A69-1602-54317", "A69-1602-54317",
"A69-1602-54318", "A69-1602-54318", "A69-1602-54319", "A69-1602-54319",
"A69-1602-54320", "A69-1602-54320", "A69-1602-54321", "A69-1602-54322",
"A69-1602-54323", "A69-1602-54323", "A69-1602-54324", "A69-1602-54325",
"A69-1602-54326", "A69-1602-54327", "A69-1602-54328", "A69-1602-59744",
"A69-1602-59745", "A69-1602-59745", "A69-1602-59745", "A69-1602-59745",
"A69-1602-59745", "A69-1602-59746", "A69-1602-59746", "A69-1602-59747",
"A69-1602-59747", "A69-1602-59747", "A69-1602-59747", "A69-1602-59747",
"A69-1602-59748", "A69-1602-59748", "A69-1602-59748", "A69-1602-59748",
"A69-1602-59749", "A69-1602-59750", "A69-1602-59750", "A69-1602-59750",
"A69-1602-59751", "A69-1602-59751", "A69-1602-59752", "A69-1602-59752",
"A69-1602-59753", "A69-1602-59753", "A69-1602-59753", "A69-1602-59753",
"A69-1602-59753", "A69-1602-59754", "A69-1602-59755", "A69-1602-59755",
"A69-1602-59755", "A69-1602-59755", "A69-1602-59755", "A69-1602-59756",
"A69-1602-59756", "A69-1602-59757", "A69-1602-59757", "A69-1602-59758",
"A69-1602-59758", "A69-1602-59758", "A69-1602-59758", "A69-1602-59758",
"A69-1602-59759", "A69-1602-59759", "A69-1602-59759", "A69-1602-59759",
"A69-1602-59760", "A69-1602-59760", "A69-1602-59761", "A69-1602-59761",
"A69-1602-59761", "A69-1602-59761", "A69-1602-59761", "A69-1602-59762",
"A69-1602-59762", "A69-1602-59763", "A69-1602-59763", "A69-1602-59763",
"A69-1602-59763", "A69-1602-59763", "A69-1602-59764", "A69-1602-59764",
"A69-1602-59764", "A69-1602-59764", "A69-1602-59764", "A69-1602-59765",
"A69-1602-59765", "A69-1602-59766", "A69-1602-59766", "A69-1602-59766",
"A69-1602-59766", "A69-1602-59767", "A69-1602-59767", "A69-1602-59767",
"A69-1602-59767", "A69-1602-59767", "A69-1602-59768", "A69-1602-59768",
"A69-1602-59768", "A69-1602-59768", "A69-1602-59768", "A69-1602-59769",
"A69-1602-59769", "A69-1602-59769", "A69-1602-59769", "A69-1602-59769",
"A69-1602-59770", "A69-1602-59770", "A69-1602-59771", "A69-1602-59771",
"A69-1602-59772", "A69-1602-59772", "A69-1602-59773", "A69-1602-59773",
"A69-1602-59773", "A69-1602-59773", "A69-1602-59773", "A69-1602-59774",
"A69-1602-59774", "A69-1602-59775", "A69-1602-59775", "A69-1602-59775",
"A69-1602-59775", "A69-1602-59775", "A69-1602-59776", "A69-1602-59776",
"A69-1602-59776", "A69-1602-59776", "A69-1602-59776", "A69-1602-59777",
"A69-1602-59777", "A69-1602-59777", "A69-1602-59777", "A69-1602-59777",
"A69-1602-59778", "A69-1602-59778", "A69-1602-59779", "A69-1602-59779",
"A69-1602-59779", "A69-1602-59779", "A69-1602-59780", "A69-1602-59780",
"A69-1602-59781", "A69-1602-59781", "A69-1602-59781", "A69-1602-59781",
"A69-1602-59781", "A69-1602-59782", "A69-1602-59782", "A69-1602-59783",
"A69-1602-59783", "A69-1602-59783", "A69-1602-59783", "A69-1602-59783",
"A69-1602-59784", "A69-1602-59784", "A69-1602-59784", "A69-1602-59784",
"A69-1602-59785", "A69-1602-59786", "A69-1602-59787", "A69-1602-59787",
"A69-1602-59787", "A69-1602-59787", "A69-1602-59787", "A69-1602-59788",
"A69-1602-59788", "A69-1602-59788", "A69-1602-59788", "A69-1602-59788",
"A69-1602-59789", "A69-1602-59789", "A69-1602-59789", "A69-1602-59789",
"A69-1602-59789", "A69-1602-59790", "A69-1602-59790", "A69-1602-59791",
"A69-1602-59791", "A69-1602-59792", "A69-1602-59793", "A69-1602-59793",
"A69-1602-59793", "A69-1602-59793", "A69-1602-59794", "A69-1602-59794",
"A69-1602-59795", "A69-1602-59795", "A69-1602-59796", "A69-1602-59796",
"A69-1602-59796", "A69-1602-59796", "A69-1602-59796", "A69-1602-59797",
"A69-1602-59797", "A69-1602-59798", "A69-1602-59798", "A69-1602-59799",
"A69-1602-59799", "A69-1602-59799", "A69-1602-59799", "A69-1602-59799",
"A69-1602-59800", "A69-1602-59800", "A69-1602-59801", "A69-1602-59801",
"A69-1602-59801", "A69-1602-59801", "A69-1602-59801", "A69-1602-59802",
"A69-1602-59802", "A69-1602-59803", "A69-1602-59803", "A69-1602-59803",
"A69-1602-59803", "A69-1602-59803", "A69-1602-59804", "A69-1602-59804",
"A69-1602-59805", "A69-1602-59805", "A69-1602-59806", "A69-1602-59806",
"A69-1602-59807", "A69-1602-59807", "A69-1602-59807", "A69-1602-59808",
"A69-1602-59808", "A69-1602-59809", "A69-1602-59809", "A69-1602-59810",
"A69-1602-59810", "A69-1602-59810", "A69-1602-59811", "A69-1602-59811",
"A69-1602-59812", "A69-1602-59812", "A69-1602-59813", "A69-1602-59813",
"A69-1602-59814", "A69-1602-59814", "A69-1602-59814", "A69-1602-59814",
"A69-1602-59815", "A69-1602-59815", "A69-1602-59815", "A69-1602-59815",
"A69-1602-59816", "A69-1602-59817", "A69-1602-59819", "A69-1602-59819",
"A69-1602-59820", "A69-1602-59821", "A69-1602-59821", "A69-1602-59822",
"A69-1602-59823", "A69-1602-59823", "A69-1602-59824", "A69-1602-59825",
"A69-1602-59826", "A69-1602-59826", "A69-1602-59826", "A69-1602-59827",
"A69-1602-59827", "A69-1602-59828", "A69-1602-59828", "A69-1602-59828",
"A69-1602-59828", "A69-1602-59828", "A69-1602-59829", "A69-1602-59829",
"A69-1602-59830", "A69-1602-59831", "A69-1602-59831", "A69-1602-59831",
"A69-1602-59831", "A69-1602-59831", "A69-1602-59832", "A69-1602-59833",
"A69-1602-59834", "A69-1602-59835", "A69-1602-59835", "A69-1602-59835",
"A69-1602-59835", "A69-1602-59835", "A69-1602-59836", "A69-1602-59836",
"A69-1602-59837", "A69-1602-59837", "A69-1602-59838", "A69-1602-59839",
"A69-1602-59839", "A69-1602-59840", "A69-1602-59840", "A69-1602-59841",
"A69-1602-59841", "A69-1602-59842", "A69-1602-59843", "A69-1602-59843",
"A69-1602-59843"), Season = c("Forage", "Spawn2", "Forage", "Spawn2",
"Forage", "Spawn2", "Forage", "Spawn2", "Forage", "Spawn2", "Forage",
"Spawn2", "Forage", "Spawn2", "Forage", "Spawn2", "Forage", "Spawn2",
"Forage", "Spawn2", "Spawn2", "Spawn2", "Forage", "Spawn2", "Spawn2",
"Spawn2", "Spawn2", "Spawn2", "Spawn2", "Winter1", "Forage",
"Spawn1", "Spawn2", "Winter1", "Winter2", "Spawn1", "Winter1",
"Forage", "Spawn1", "Spawn2", "Winter1", "Winter2", "Spawn1",
"Spawn2", "Winter1", "Winter2", "Spawn1", "Forage", "Winter1",
"Winter2", "Spawn1", "Winter1", "Spawn1", "Winter1", "Forage",
"Spawn1", "Spawn2", "Winter1", "Winter2", "Winter1", "Forage",
"Spawn1", "Spawn2", "Winter1", "Winter2", "Spawn1", "Winter1",
"Spawn1", "Winter1", "Forage", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Forage", "Spawn1", "Winter1", "Winter2", "Spawn1",
"Winter1", "Forage", "Spawn1", "Spawn2", "Winter1", "Winter2",
"Spawn1", "Winter1", "Forage", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Forage", "Spawn1", "Spawn2", "Winter1", "Winter2",
"Spawn1", "Winter1", "Spawn1", "Spawn2", "Winter1", "Winter2",
"Forage", "Spawn1", "Spawn2", "Winter1", "Winter2", "Forage",
"Spawn1", "Spawn2", "Winter1", "Winter2", "Forage", "Spawn1",
"Spawn2", "Winter1", "Winter2", "Spawn1", "Winter1", "Spawn1",
"Winter1", "Spawn1", "Winter1", "Forage", "Spawn1", "Spawn2",
"Winter1", "Winter2", "Spawn1", "Winter1", "Forage", "Spawn1",
"Spawn2", "Winter1", "Winter2", "Forage", "Spawn1", "Spawn2",
"Winter1", "Winter2", "Forage", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Spawn1", "Winter1", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Spawn1", "Winter1", "Forage", "Spawn1", "Spawn2",
"Winter1", "Winter2", "Spawn1", "Winter1", "Forage", "Spawn1",
"Spawn2", "Winter1", "Winter2", "Forage", "Spawn1", "Spawn2",
"Winter1", "Winter1", "Winter1", "Forage", "Spawn1", "Spawn2",
"Winter1", "Winter2", "Forage", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Forage", "Spawn1", "Spawn2", "Winter1", "Winter2",
"Spawn1", "Winter1", "Spawn1", "Winter1", "Winter1", "Forage",
"Spawn1", "Winter1", "Winter2", "Spawn1", "Winter1", "Spawn1",
"Winter1", "Forage", "Spawn1", "Spawn2", "Winter1", "Winter2",
"Spawn1", "Winter1", "Spawn1", "Winter1", "Forage", "Spawn1",
"Spawn2", "Winter1", "Winter2", "Spawn1", "Winter1", "Forage",
"Spawn1", "Spawn2", "Winter1", "Winter2", "Spawn1", "Winter1",
"Forage", "Spawn1", "Spawn2", "Winter1", "Winter2", "Spawn1",
"Winter1", "Spawn1", "Winter1", "Spawn1", "Winter1", "Forage",
"Spawn1", "Winter1", "Spawn1", "Winter1", "Spawn1", "Winter1",
"Forage", "Spawn1", "Winter1", "Spawn1", "Winter1", "Spawn1",
"Winter1", "Spawn1", "Winter1", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Spawn1", "Spawn2", "Winter1", "Winter2", "Winter1",
"Winter1", "Spawn1", "Winter1", "Winter1", "Spawn1", "Winter1",
"Winter1", "Spawn1", "Winter1", "Winter1", "Winter1", "Spawn1",
"Winter1", "Winter2", "Spawn1", "Winter1", "Forage", "Spawn1",
"Spawn2", "Winter1", "Winter2", "Forage", "Spawn1", "Winter1",
"Forage", "Spawn1", "Spawn2", "Winter1", "Winter2", "Winter1",
"Winter1", "Winter1", "Forage", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Spawn1", "Winter1", "Spawn1", "Winter1", "Winter1",
"Spawn1", "Winter1", "Spawn1", "Winter1", "Spawn1", "Winter1",
"Winter1", "Forage", "Spawn1", "Winter1"), Batch.location = structure(c(8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
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, 7L, 7L, 7L, 7L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
3L, 3L, 3L, 3L, 3L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L), .Label = c("Den Oever", "Medemblik",
"Enkhuizen", "Stavoren", "Lemmer", "Ketelhaven", "Lelystad",
"Markerwadden"), class = "factor"), `max distance` = c(2.09861304168527,
2.52186862327424, 2.09861304168527, 2.09861304168527, 2.06773203256743,
2.09861304168527, 2.09861304168527, 2.52186862327424, 2.06773203256743,
2.09861304168527, 2.09861304168527, 2.09861304168527, 0.207052365336615,
2.09861304168527, 2.09861304168527, 2.09861304168527, 2.09861304168527,
2.27221768516951, 2.09861304168527, 2.52186862327424, 2.09861304168527,
2.52186862327424, 2.09861304168527, 2.52186862327424, 0.207052365336615,
2.52186862327424, 0.207052365336615, 2.09861304168527, 2.09861304168527,
2.55827101689345, 2.55827101689345, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 29.6222537752041, 2.55827101689345,
0, 2.55827101689345, 2.55827101689345, 2.55827101689345, 2.55827101689345,
2.55827101689345, 13.6078290874409, 2.55827101689345, 0, 4.07525961740185,
14.7442644338329, 0, 14.7442644338329, 14.7442644338329, 14.7442644338329,
14.7442644338329, 0, 0, 0, 0, 0, 0, 3.67357267678004, 14.7442644338329,
31.8861260921355, 31.8861260921355, 14.7442644338329, 14.7442644338329,
0, 3.67357267678004, 31.8861260921355, 0, 0, 0, 0, 14.1891547888285,
3.67357267678004, 13.6078290874409, 53.9604508112108, 39.9833461407132,
13.6078290874409, 1.60673719243843, 1.60673719243843, 18.8755486336044,
37.1477457727004, 37.1477457727004, 1.60673719243843, 0, 2.93233568869472,
1.60673719243843, 0, 1.60673719243843, 0, 18.8755486336044, 0,
0, 2.93233568869472, 2.93233568869472, 2.93233568869472, 2.93233568869472,
2.93233568869472, 2.93233568869472, 13.6078290874409, 13.6078290874409,
2.93233568869472, 0, 0, 2.93233568869472, 2.93233568869472, 2.93233568869472,
2.93233568869472, 0, 2.93233568869472, 2.93233568869472, 2.93233568869472,
2.93233568869472, 0, 0, 0, 0, 0, 22.0689264444271, 22.0689264444271,
21.6573593129425, 0, 0, 0, 0, 21.6573593129425, 21.6573593129425,
0, 0, 27.1352921526802, 27.1352921526802, 0, 21.6573593129425,
21.6573593129425, 0, 0, 0, 0, 0, 17.2740564735626, 0, 18.8755486336044,
0, 0, 0, 0, 22.0689264444271, 0, 34.0126665945869, 31.5589537736477,
31.5589537736477, 22.1776822695344, 0, 22.1776822695344, 31.389797027264,
44.5900705020792, 43.3976533332777, 31.389797027264, 43.3976533332777,
14.8691518778998, 14.8691518778998, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 2.55827101689345, 14.5827981937255,
15.7089215225545, 14.5827981937255, 2.55827101689345, 2.55827101689345,
2.55827101689345, 0, 2.55827101689345, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 0, 0, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 17.5361439864551, 0, 17.5361439864551,
31.5589537736477, 0, 17.5361439864551, 17.5361439864551, 0, 0,
30.1390542608465, 31.5589537736477, 17.5361439864551, 0, 22.1776822695344,
38.0419064223524, 22.1776822695344, 26.4325286192825, 38.0419064223524,
0, 0, 0, 17.5361439864551, 17.5361439864551, 0, 0, 17.5361439864551,
17.5361439864551, 0, 17.5361439864551, 0, 0, 0, 30.1390542608465,
0, 30.1390542608465, 0, 1.48108027988229, 1.48108027988229, 17.6313494625488,
30.1390542608465, 18.5565893657245, 29.6361491030785, 0, 17.5361439864551,
7.13622984428536, 1.48108027988229, 22.1776822695344, 22.1776822695344,
35.5520908555987, 21.0650298743005, 59.7128353277037, 31.5589537736477,
17.5361439864551, 17.5361439864551, 2.25656968299054, 2.25656968299054,
2.25656968299054, 2.25656968299054, 0, 0, 0, 0, 52.5465855455931,
21.2040865946565, 2.25656968299054, 0, 0, 0, 21.2040865946565,
0, 0, 0, 0, 38.2165754172804, 0, 0, 0, 0, 0, 31.8861260921355,
21.2040865946565, 21.2040865946565, 21.2040865946565, 33.4969050950683,
26.4925842074686, 0, 0, 0, 2.25656968299054, 2.25656968299054,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.25656968299054, 0, 21.2040865946565,
21.2040865946565, 21.2040865946565, 21.2040865946565, 21.2040865946565,
21.2040865946565, 21.2040865946565, 64.1655009571088, 43.8757964958802,
0, 21.6264847096301, 21.6264847096301, 21.2040865946565), group = structure(c(6L,
6L, 6L, 6L, 6L, 6L, 6L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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1)), row.names = c(NA, -311L), class = c("tbl_df",
"tbl", "data.frame"))
[1]: https://i.stack.imgur.com/5D1CE.png
scale_fill_discrete()
用于 6 个级别的默认颜色可以使用 scales::hue_pal()
:
生成
> my_colors = scales::hue_pal()(6)
> my_colors
[1] "#F8766D" "#B79F00" "#00BA38" "#00BFC4" "#619CFF" "#F564E3"
最后一个颜色对应的是你不喜欢的亮粉色。你可以把它改成紫色:
my_colors[6] = "#C77CFF"
然后,use scale_fill_manual
使用这组颜色:
ggplot(Dispersion3, aes(Batch.location, Number, fill=group))+
geom_bar(stat='identity')+
scale_x_discrete(guide = guide_axis(angle = 45))+
facet_grid(~factor(Season, levels=c("Winter1", "Spawn1", "Forage", "Winter2", "Spawn2"), labels = c("Winter-19/20", "Spawn-20", "Forage-20", "Winter-20/21", "Spawn-21")))+
scale_fill_manual(
name = "Distance from batch",
labels = c("> 40 km", "30 - 40 km", "20 - 30 km", "10 - 20 km", "5 - 10 km", "< 5 km"),
values = my_colors
)
我想(手动)改变条形图的颜色。现在,我使用 fill=group
来确定配色方案。但是,我不喜欢亮粉色,想手动改成紫色,其他颜色都可以。如何在不改变图表其余部分的情况下更改颜色?
我在条形图中使用了以下命令:
ggplot(Dispersion3, aes(Batch.location, Number, fill=group))+
geom_bar(stat='identity')+
scale_x_discrete(guide = guide_axis(angle = 45))+
facet_grid(~factor(Season, levels=c("Winter1", "Spawn1", "Forage", "Winter2", "Spawn2"), labels = c("Winter-19/20", "Spawn-20", "Forage-20", "Winter-20/21", "Spawn-21")))+
scale_fill_discrete(name = "Distance from batch", labels = c("> 40 km", "30 - 40 km", "20 - 30 km", "10 - 20 km", "5 - 10 km", "< 5 km"))
[![在此处输入图片描述][1]][1]
数据=色散3
structure(list(Transmitter = c("A69-1602-54311", "A69-1602-54311",
"A69-1602-54312", "A69-1602-54312", "A69-1602-54313", "A69-1602-54313",
"A69-1602-54314", "A69-1602-54314", "A69-1602-54315", "A69-1602-54315",
"A69-1602-54316", "A69-1602-54316", "A69-1602-54317", "A69-1602-54317",
"A69-1602-54318", "A69-1602-54318", "A69-1602-54319", "A69-1602-54319",
"A69-1602-54320", "A69-1602-54320", "A69-1602-54321", "A69-1602-54322",
"A69-1602-54323", "A69-1602-54323", "A69-1602-54324", "A69-1602-54325",
"A69-1602-54326", "A69-1602-54327", "A69-1602-54328", "A69-1602-59744",
"A69-1602-59745", "A69-1602-59745", "A69-1602-59745", "A69-1602-59745",
"A69-1602-59745", "A69-1602-59746", "A69-1602-59746", "A69-1602-59747",
"A69-1602-59747", "A69-1602-59747", "A69-1602-59747", "A69-1602-59747",
"A69-1602-59748", "A69-1602-59748", "A69-1602-59748", "A69-1602-59748",
"A69-1602-59749", "A69-1602-59750", "A69-1602-59750", "A69-1602-59750",
"A69-1602-59751", "A69-1602-59751", "A69-1602-59752", "A69-1602-59752",
"A69-1602-59753", "A69-1602-59753", "A69-1602-59753", "A69-1602-59753",
"A69-1602-59753", "A69-1602-59754", "A69-1602-59755", "A69-1602-59755",
"A69-1602-59755", "A69-1602-59755", "A69-1602-59755", "A69-1602-59756",
"A69-1602-59756", "A69-1602-59757", "A69-1602-59757", "A69-1602-59758",
"A69-1602-59758", "A69-1602-59758", "A69-1602-59758", "A69-1602-59758",
"A69-1602-59759", "A69-1602-59759", "A69-1602-59759", "A69-1602-59759",
"A69-1602-59760", "A69-1602-59760", "A69-1602-59761", "A69-1602-59761",
"A69-1602-59761", "A69-1602-59761", "A69-1602-59761", "A69-1602-59762",
"A69-1602-59762", "A69-1602-59763", "A69-1602-59763", "A69-1602-59763",
"A69-1602-59763", "A69-1602-59763", "A69-1602-59764", "A69-1602-59764",
"A69-1602-59764", "A69-1602-59764", "A69-1602-59764", "A69-1602-59765",
"A69-1602-59765", "A69-1602-59766", "A69-1602-59766", "A69-1602-59766",
"A69-1602-59766", "A69-1602-59767", "A69-1602-59767", "A69-1602-59767",
"A69-1602-59767", "A69-1602-59767", "A69-1602-59768", "A69-1602-59768",
"A69-1602-59768", "A69-1602-59768", "A69-1602-59768", "A69-1602-59769",
"A69-1602-59769", "A69-1602-59769", "A69-1602-59769", "A69-1602-59769",
"A69-1602-59770", "A69-1602-59770", "A69-1602-59771", "A69-1602-59771",
"A69-1602-59772", "A69-1602-59772", "A69-1602-59773", "A69-1602-59773",
"A69-1602-59773", "A69-1602-59773", "A69-1602-59773", "A69-1602-59774",
"A69-1602-59774", "A69-1602-59775", "A69-1602-59775", "A69-1602-59775",
"A69-1602-59775", "A69-1602-59775", "A69-1602-59776", "A69-1602-59776",
"A69-1602-59776", "A69-1602-59776", "A69-1602-59776", "A69-1602-59777",
"A69-1602-59777", "A69-1602-59777", "A69-1602-59777", "A69-1602-59777",
"A69-1602-59778", "A69-1602-59778", "A69-1602-59779", "A69-1602-59779",
"A69-1602-59779", "A69-1602-59779", "A69-1602-59780", "A69-1602-59780",
"A69-1602-59781", "A69-1602-59781", "A69-1602-59781", "A69-1602-59781",
"A69-1602-59781", "A69-1602-59782", "A69-1602-59782", "A69-1602-59783",
"A69-1602-59783", "A69-1602-59783", "A69-1602-59783", "A69-1602-59783",
"A69-1602-59784", "A69-1602-59784", "A69-1602-59784", "A69-1602-59784",
"A69-1602-59785", "A69-1602-59786", "A69-1602-59787", "A69-1602-59787",
"A69-1602-59787", "A69-1602-59787", "A69-1602-59787", "A69-1602-59788",
"A69-1602-59788", "A69-1602-59788", "A69-1602-59788", "A69-1602-59788",
"A69-1602-59789", "A69-1602-59789", "A69-1602-59789", "A69-1602-59789",
"A69-1602-59789", "A69-1602-59790", "A69-1602-59790", "A69-1602-59791",
"A69-1602-59791", "A69-1602-59792", "A69-1602-59793", "A69-1602-59793",
"A69-1602-59793", "A69-1602-59793", "A69-1602-59794", "A69-1602-59794",
"A69-1602-59795", "A69-1602-59795", "A69-1602-59796", "A69-1602-59796",
"A69-1602-59796", "A69-1602-59796", "A69-1602-59796", "A69-1602-59797",
"A69-1602-59797", "A69-1602-59798", "A69-1602-59798", "A69-1602-59799",
"A69-1602-59799", "A69-1602-59799", "A69-1602-59799", "A69-1602-59799",
"A69-1602-59800", "A69-1602-59800", "A69-1602-59801", "A69-1602-59801",
"A69-1602-59801", "A69-1602-59801", "A69-1602-59801", "A69-1602-59802",
"A69-1602-59802", "A69-1602-59803", "A69-1602-59803", "A69-1602-59803",
"A69-1602-59803", "A69-1602-59803", "A69-1602-59804", "A69-1602-59804",
"A69-1602-59805", "A69-1602-59805", "A69-1602-59806", "A69-1602-59806",
"A69-1602-59807", "A69-1602-59807", "A69-1602-59807", "A69-1602-59808",
"A69-1602-59808", "A69-1602-59809", "A69-1602-59809", "A69-1602-59810",
"A69-1602-59810", "A69-1602-59810", "A69-1602-59811", "A69-1602-59811",
"A69-1602-59812", "A69-1602-59812", "A69-1602-59813", "A69-1602-59813",
"A69-1602-59814", "A69-1602-59814", "A69-1602-59814", "A69-1602-59814",
"A69-1602-59815", "A69-1602-59815", "A69-1602-59815", "A69-1602-59815",
"A69-1602-59816", "A69-1602-59817", "A69-1602-59819", "A69-1602-59819",
"A69-1602-59820", "A69-1602-59821", "A69-1602-59821", "A69-1602-59822",
"A69-1602-59823", "A69-1602-59823", "A69-1602-59824", "A69-1602-59825",
"A69-1602-59826", "A69-1602-59826", "A69-1602-59826", "A69-1602-59827",
"A69-1602-59827", "A69-1602-59828", "A69-1602-59828", "A69-1602-59828",
"A69-1602-59828", "A69-1602-59828", "A69-1602-59829", "A69-1602-59829",
"A69-1602-59830", "A69-1602-59831", "A69-1602-59831", "A69-1602-59831",
"A69-1602-59831", "A69-1602-59831", "A69-1602-59832", "A69-1602-59833",
"A69-1602-59834", "A69-1602-59835", "A69-1602-59835", "A69-1602-59835",
"A69-1602-59835", "A69-1602-59835", "A69-1602-59836", "A69-1602-59836",
"A69-1602-59837", "A69-1602-59837", "A69-1602-59838", "A69-1602-59839",
"A69-1602-59839", "A69-1602-59840", "A69-1602-59840", "A69-1602-59841",
"A69-1602-59841", "A69-1602-59842", "A69-1602-59843", "A69-1602-59843",
"A69-1602-59843"), Season = c("Forage", "Spawn2", "Forage", "Spawn2",
"Forage", "Spawn2", "Forage", "Spawn2", "Forage", "Spawn2", "Forage",
"Spawn2", "Forage", "Spawn2", "Forage", "Spawn2", "Forage", "Spawn2",
"Forage", "Spawn2", "Spawn2", "Spawn2", "Forage", "Spawn2", "Spawn2",
"Spawn2", "Spawn2", "Spawn2", "Spawn2", "Winter1", "Forage",
"Spawn1", "Spawn2", "Winter1", "Winter2", "Spawn1", "Winter1",
"Forage", "Spawn1", "Spawn2", "Winter1", "Winter2", "Spawn1",
"Spawn2", "Winter1", "Winter2", "Spawn1", "Forage", "Winter1",
"Winter2", "Spawn1", "Winter1", "Spawn1", "Winter1", "Forage",
"Spawn1", "Spawn2", "Winter1", "Winter2", "Winter1", "Forage",
"Spawn1", "Spawn2", "Winter1", "Winter2", "Spawn1", "Winter1",
"Spawn1", "Winter1", "Forage", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Forage", "Spawn1", "Winter1", "Winter2", "Spawn1",
"Winter1", "Forage", "Spawn1", "Spawn2", "Winter1", "Winter2",
"Spawn1", "Winter1", "Forage", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Forage", "Spawn1", "Spawn2", "Winter1", "Winter2",
"Spawn1", "Winter1", "Spawn1", "Spawn2", "Winter1", "Winter2",
"Forage", "Spawn1", "Spawn2", "Winter1", "Winter2", "Forage",
"Spawn1", "Spawn2", "Winter1", "Winter2", "Forage", "Spawn1",
"Spawn2", "Winter1", "Winter2", "Spawn1", "Winter1", "Spawn1",
"Winter1", "Spawn1", "Winter1", "Forage", "Spawn1", "Spawn2",
"Winter1", "Winter2", "Spawn1", "Winter1", "Forage", "Spawn1",
"Spawn2", "Winter1", "Winter2", "Forage", "Spawn1", "Spawn2",
"Winter1", "Winter2", "Forage", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Spawn1", "Winter1", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Spawn1", "Winter1", "Forage", "Spawn1", "Spawn2",
"Winter1", "Winter2", "Spawn1", "Winter1", "Forage", "Spawn1",
"Spawn2", "Winter1", "Winter2", "Forage", "Spawn1", "Spawn2",
"Winter1", "Winter1", "Winter1", "Forage", "Spawn1", "Spawn2",
"Winter1", "Winter2", "Forage", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Forage", "Spawn1", "Spawn2", "Winter1", "Winter2",
"Spawn1", "Winter1", "Spawn1", "Winter1", "Winter1", "Forage",
"Spawn1", "Winter1", "Winter2", "Spawn1", "Winter1", "Spawn1",
"Winter1", "Forage", "Spawn1", "Spawn2", "Winter1", "Winter2",
"Spawn1", "Winter1", "Spawn1", "Winter1", "Forage", "Spawn1",
"Spawn2", "Winter1", "Winter2", "Spawn1", "Winter1", "Forage",
"Spawn1", "Spawn2", "Winter1", "Winter2", "Spawn1", "Winter1",
"Forage", "Spawn1", "Spawn2", "Winter1", "Winter2", "Spawn1",
"Winter1", "Spawn1", "Winter1", "Spawn1", "Winter1", "Forage",
"Spawn1", "Winter1", "Spawn1", "Winter1", "Spawn1", "Winter1",
"Forage", "Spawn1", "Winter1", "Spawn1", "Winter1", "Spawn1",
"Winter1", "Spawn1", "Winter1", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Spawn1", "Spawn2", "Winter1", "Winter2", "Winter1",
"Winter1", "Spawn1", "Winter1", "Winter1", "Spawn1", "Winter1",
"Winter1", "Spawn1", "Winter1", "Winter1", "Winter1", "Spawn1",
"Winter1", "Winter2", "Spawn1", "Winter1", "Forage", "Spawn1",
"Spawn2", "Winter1", "Winter2", "Forage", "Spawn1", "Winter1",
"Forage", "Spawn1", "Spawn2", "Winter1", "Winter2", "Winter1",
"Winter1", "Winter1", "Forage", "Spawn1", "Spawn2", "Winter1",
"Winter2", "Spawn1", "Win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L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L), .Label = c("Den Oever", "Medemblik",
"Enkhuizen", "Stavoren", "Lemmer", "Ketelhaven", "Lelystad",
"Markerwadden"), class = "factor"), `max distance` = c(2.09861304168527,
2.52186862327424, 2.09861304168527, 2.09861304168527, 2.06773203256743,
2.09861304168527, 2.09861304168527, 2.52186862327424, 2.06773203256743,
2.09861304168527, 2.09861304168527, 2.09861304168527, 0.207052365336615,
2.09861304168527, 2.09861304168527, 2.09861304168527, 2.09861304168527,
2.27221768516951, 2.09861304168527, 2.52186862327424, 2.09861304168527,
2.52186862327424, 2.09861304168527, 2.52186862327424, 0.207052365336615,
2.52186862327424, 0.207052365336615, 2.09861304168527, 2.09861304168527,
2.55827101689345, 2.55827101689345, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 29.6222537752041, 2.55827101689345,
0, 2.55827101689345, 2.55827101689345, 2.55827101689345, 2.55827101689345,
2.55827101689345, 13.6078290874409, 2.55827101689345, 0, 4.07525961740185,
14.7442644338329, 0, 14.7442644338329, 14.7442644338329, 14.7442644338329,
14.7442644338329, 0, 0, 0, 0, 0, 0, 3.67357267678004, 14.7442644338329,
31.8861260921355, 31.8861260921355, 14.7442644338329, 14.7442644338329,
0, 3.67357267678004, 31.8861260921355, 0, 0, 0, 0, 14.1891547888285,
3.67357267678004, 13.6078290874409, 53.9604508112108, 39.9833461407132,
13.6078290874409, 1.60673719243843, 1.60673719243843, 18.8755486336044,
37.1477457727004, 37.1477457727004, 1.60673719243843, 0, 2.93233568869472,
1.60673719243843, 0, 1.60673719243843, 0, 18.8755486336044, 0,
0, 2.93233568869472, 2.93233568869472, 2.93233568869472, 2.93233568869472,
2.93233568869472, 2.93233568869472, 13.6078290874409, 13.6078290874409,
2.93233568869472, 0, 0, 2.93233568869472, 2.93233568869472, 2.93233568869472,
2.93233568869472, 0, 2.93233568869472, 2.93233568869472, 2.93233568869472,
2.93233568869472, 0, 0, 0, 0, 0, 22.0689264444271, 22.0689264444271,
21.6573593129425, 0, 0, 0, 0, 21.6573593129425, 21.6573593129425,
0, 0, 27.1352921526802, 27.1352921526802, 0, 21.6573593129425,
21.6573593129425, 0, 0, 0, 0, 0, 17.2740564735626, 0, 18.8755486336044,
0, 0, 0, 0, 22.0689264444271, 0, 34.0126665945869, 31.5589537736477,
31.5589537736477, 22.1776822695344, 0, 22.1776822695344, 31.389797027264,
44.5900705020792, 43.3976533332777, 31.389797027264, 43.3976533332777,
14.8691518778998, 14.8691518778998, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 2.55827101689345, 14.5827981937255,
15.7089215225545, 14.5827981937255, 2.55827101689345, 2.55827101689345,
2.55827101689345, 0, 2.55827101689345, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 0, 0, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 2.55827101689345, 2.55827101689345,
2.55827101689345, 2.55827101689345, 17.5361439864551, 0, 17.5361439864551,
31.5589537736477, 0, 17.5361439864551, 17.5361439864551, 0, 0,
30.1390542608465, 31.5589537736477, 17.5361439864551, 0, 22.1776822695344,
38.0419064223524, 22.1776822695344, 26.4325286192825, 38.0419064223524,
0, 0, 0, 17.5361439864551, 17.5361439864551, 0, 0, 17.5361439864551,
17.5361439864551, 0, 17.5361439864551, 0, 0, 0, 30.1390542608465,
0, 30.1390542608465, 0, 1.48108027988229, 1.48108027988229, 17.6313494625488,
30.1390542608465, 18.5565893657245, 29.6361491030785, 0, 17.5361439864551,
7.13622984428536, 1.48108027988229, 22.1776822695344, 22.1776822695344,
35.5520908555987, 21.0650298743005, 59.7128353277037, 31.5589537736477,
17.5361439864551, 17.5361439864551, 2.25656968299054, 2.25656968299054,
2.25656968299054, 2.25656968299054, 0, 0, 0, 0, 52.5465855455931,
21.2040865946565, 2.25656968299054, 0, 0, 0, 21.2040865946565,
0, 0, 0, 0, 38.2165754172804, 0, 0, 0, 0, 0, 31.8861260921355,
21.2040865946565, 21.2040865946565, 21.2040865946565, 33.4969050950683,
26.4925842074686, 0, 0, 0, 2.25656968299054, 2.25656968299054,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.25656968299054, 0, 21.2040865946565,
21.2040865946565, 21.2040865946565, 21.2040865946565, 21.2040865946565,
21.2040865946565, 21.2040865946565, 64.1655009571088, 43.8757964958802,
0, 21.6264847096301, 21.6264847096301, 21.2040865946565), group = structure(c(6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 4L, 6L, 6L, 6L, 4L, 6L,
4L, 4L, 4L, 4L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 4L, 2L, 2L, 4L, 4L,
6L, 6L, 2L, 6L, 6L, 6L, 6L, 4L, 6L, 4L, 1L, 2L, 4L, 6L, 6L, 4L,
2L, 2L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 4L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 4L, 4L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6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, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1)), row.names = c(NA, -311L), class = c("tbl_df",
"tbl", "data.frame"))
[1]: https://i.stack.imgur.com/5D1CE.png
scale_fill_discrete()
用于 6 个级别的默认颜色可以使用 scales::hue_pal()
:
> my_colors = scales::hue_pal()(6)
> my_colors
[1] "#F8766D" "#B79F00" "#00BA38" "#00BFC4" "#619CFF" "#F564E3"
最后一个颜色对应的是你不喜欢的亮粉色。你可以把它改成紫色:
my_colors[6] = "#C77CFF"
然后,use scale_fill_manual
使用这组颜色:
ggplot(Dispersion3, aes(Batch.location, Number, fill=group))+
geom_bar(stat='identity')+
scale_x_discrete(guide = guide_axis(angle = 45))+
facet_grid(~factor(Season, levels=c("Winter1", "Spawn1", "Forage", "Winter2", "Spawn2"), labels = c("Winter-19/20", "Spawn-20", "Forage-20", "Winter-20/21", "Spawn-21")))+
scale_fill_manual(
name = "Distance from batch",
labels = c("> 40 km", "30 - 40 km", "20 - 30 km", "10 - 20 km", "5 - 10 km", "< 5 km"),
values = my_colors
)