Created
August 18, 2020 03:58
-
-
Save JustinWenzhaoLi/130e47962a5e4bc77b4c75bd4022a0ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(raster) | |
| library(rgdal) | |
| library(dplyr) | |
| r1 <- raster("pop_GERMANY.tif") | |
| r1 <-r1[(r1 > 1)] | |
| # boxplot(r1, log="y", outline=TRUE, ylim = c(1, 30000), main='Germany', ylab='Population Density (km^2)' ) | |
| library(ggplot2) | |
| library(ggExtra) | |
| s1 <- data.frame(r1) | |
| # Basic violin plot | |
| p1 <- ggplot(s1, aes(y=r1)) + | |
| geom_boxplot()+ | |
| ylab("Population per km^2") + | |
| xlab("Germany") + | |
| scale_y_continuous(trans='log10', limits = c(1, 30000)) + | |
| theme_bw()+ | |
| theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) | |
| p1 | |
| d1 <- ggplot(s1, aes(y=r1)) + | |
| geom_density()+ | |
| xlab("Density") + | |
| xlim(0,2)+ | |
| scale_y_continuous(trans='log10', limits = c(1, 30000)) + | |
| theme_bw()+ | |
| theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) + | |
| theme(axis.text.y=element_blank(), | |
| axis.ticks.y=element_blank(), | |
| axis.title.y=element_blank()) | |
| d1 | |
| h1 <- ggplot(s1, aes(y=r1)) + | |
| geom_histogram(bins = 30)+ | |
| xlab("# of pixels") + | |
| xlim(0,100000) + | |
| scale_y_continuous(trans='log10', limits = c(1, 30000)) + | |
| theme_bw()+ | |
| theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) + | |
| theme(axis.text.y=element_blank(), | |
| axis.ticks.y=element_blank(), | |
| axis.title.y=element_blank()) | |
| h1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment