Created
November 9, 2017 16:43
-
-
Save x-raizor/38595de4c911d5b9b29adc0260d345c6 to your computer and use it in GitHub Desktop.
Scatterplot with marginal histograms
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
| # Combine histogram scater and barchart in one plot | |
| top_hist <- ggplot(dataset, aes(date, shipped)) + geom_col() + | |
| theme(axis.ticks=element_blank(), panel.background=element_blank(), | |
| axis.text.x=element_blank(), axis.title.x=element_blank(), | |
| axis.title.y=element_blank()) | |
| right_hist <- ggplot(dataset) + geom_histogram(aes(shipped), binwidth = 1) + coord_flip() + | |
| scale_x_continuous(expand=c(0, 0)) + scale_y_continuous(expand=c(0, 0)) + | |
| theme(axis.ticks=element_blank(), panel.background=element_blank(), | |
| axis.text.y=element_blank(), axis.title.y=element_blank()) + ylab('') | |
| scatter <- ggplot(dataset, aes(date, shipped)) + | |
| geom_point(alpha=0.5, size=0.75) + theme_bw() | |
| empty <- ggplot()+geom_point(aes(1,1), colour="white") + | |
| theme(axis.ticks=element_blank(), | |
| panel.background=element_blank(), | |
| axis.text.x=element_blank(), axis.text.y=element_blank(), | |
| axis.title.x=element_blank(), axis.title.y=element_blank()) | |
| grid.arrange(top_hist, empty, scatter, right_hist, ncol=2, nrow=2, widths=c(4, 1), heights=c(1, 4)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment