geom_bin2d | ggplot example2

geom_bin2d | ggplot example2

Quick Start

library(ggplot2)
library(ggthemes)

world <- map_data("world")
ggplot(world, aes(long, lat)) + geom_bin2d() + theme_map()

Arguments

bins

x=y=bins+1

library(patchwork)

P1 <- ggplot(world, aes( long, lat)) +geom_bin2d(bins = 10) + theme_map() +
ggtitle('bins=10')+ theme(plot.title = element_text(hjust=0.5,size=20))
P2 <- ggplot(world, aes( long, lat)) +geom_bin2d(bins = 100) + theme_map() +
ggtitle('bins=100')+ theme(plot.title = element_text(hjust=0.5,size=20))

P1/P2

Nu8yon.png

binwidth

library(RColorBrewer)
library(patchwork)


colorRampPalette(rev(brewer.pal(n = 7,name = "RdYlBu"))) -> cc

P1 <- ggplot(world, aes( long, lat)) +geom_bin2d(binwidth = c(0.1, 0.1))+
theme_map() +ggtitle('0.1 0.1')+ theme(plot.title = element_text(hjust=0.5,size=20))+
scale_fill_gradientn(colors=cc(100))
P2 <- ggplot(world, aes( long, lat)) +geom_bin2d(binwidth = c(0.1, 10))+
theme_map() +ggtitle('0.1 10')+ theme(plot.title = element_text(hjust=0.5,size=20))+
scale_fill_gradientn(colors=cc(100))
P3 <- ggplot(world, aes( long, lat)) +geom_bin2d(binwidth = c(10, 0.1))+
theme_map() +ggtitle('10 0.1')+ theme(plot.title = element_text(hjust=0.5,size=20))+
scale_fill_gradientn(colors=cc(100))
P4 <- ggplot(world, aes( long, lat)) +geom_bin2d(binwidth = c(10, 10))+
theme_map() +ggtitle('10 10')+ theme(plot.title = element_text(hjust=0.5,size=20))+
scale_fill_gradientn(colors=cc(100))

(P1|P2)/(P4|P3)

bin2

More

Author

Karobben

Posted on

2020-06-19

Updated on

2024-01-22

Licensed under

Comments