ich habe meine Daten mithilfe von gglpot2 in einem Raster dargestellt. Die NAs sind dabei rot eingefärbt, nun würde ich diese auch gerne in der Legende angezeigt haben (z.b. einfach als kleines Rotes Kästchen,...), habe dazu aber leider noch keine Lösung, da sie ja in meinem Datensatz drin sind und keine eigene Struktur haben, und würde mich freuen, wenn jemand eine Idee dafür hätte.
Meine Daten:
Code: Alles auswählen
Profile<-structure(list(Profil = c(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4,
5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11,
11, 11, 12, 12, 12), Tiefe = c(0.1, 0.3, 0.5, 0.1, 0.3, 0.5,
0.1, 0.3, 0.5, 0.1, 0.3, 0.5, 0.1, 0.3, 0.5, 0.1, 0.3, 0.5, 0.1,
0.3, 0.5, 0.1, 0.3, 0.5, 0.1, 0.3, 0.5, 0.1, 0.3, 0.5, 0.1, 0.3,
0.5, 0.1, 0.3, 0.5), Wert = c(438.4, 156.2, 210.6, 1, 0.5, 1.3,
1.1, 0.5, NA, NA, NA, 1000, 906.47, 24.17, 0.22, 0, 0.34, 0.51,
0.45, 0, 0.08, 0.03, 2.76, 0.29, 13.03, 65.33, 0.01, 0.34, 0.09,
0.02, 0.02, 2.23, 0.21, NA, NA, 2.21), Linie = c(0.15, 0.15,
0.15, 0.24, 0.24, 0.24, 0.13, 0.13, 0.13, 0.45, 0.45, 0.45, 0.31,
0.31, 0.31, 0.21, 0.21, 0.21, 0.35, 0.35, 0.35, 0.5, 0.5, 0.5,
0.42, 0.42, 0.42, 0.43, 0.43, 0.43, 0.1, 0.1, 0.1, 0.3, 0.3,
0.3)), class = "data.frame", row.names = c(NA, -36L))
Code: Alles auswählen
ggplot(Profile, aes(Profil, Tiefe))+geom_raster(aes(fill=Wert), interpolate=TRUE)+facet_wrap(~Profil, scales = "free")+scale_fill_continuous(name= "Value",breaks=c(0,200,400,600,800,1000), na.value="red",labels=c("0","200", "400", "600", "800", "1000"))
Code: Alles auswählen
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_3.3.2
loaded via a namespace (and not attached):
[1] fansi_0.4.1 digest_0.6.27 withr_2.3.0 assertthat_0.2.1 crayon_1.3.4 grid_4.0.3 R6_2.5.0 lifecycle_0.2.0
[9] gtable_0.3.0 magrittr_2.0.1 scales_1.1.1 pillar_1.4.7 cli_2.2.0 rlang_0.4.9 farver_2.0.3 rstudioapi_0.13
[17] vctrs_0.3.6 ellipsis_0.3.1 labeling_0.4.2 tools_4.0.3 glue_1.4.2 munsell_0.5.0 compiler_4.0.3 pkgconfig_2.0.3
Cacadu