Created
April 1, 2020 20:59
-
-
Save baptiste/cee64b5bf753dca35a5d5c9aa927e234 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(ggplot2) | |
library(egg) | |
library(extrafont) | |
library(xkcd) | |
library(grid) | |
d <- data.frame(x=rep(-1:1,3),y=0,facet=rep(1:3,each=3)) | |
p0 <- ggplot(d, aes(x,y)) + | |
facet_wrap(~facet, labeller = label_both) + | |
geom_blank() + | |
xkcdaxis(c(-1,1),c(-1,1)) + | |
theme(axis.text = element_blank(), | |
axis.ticks = element_blank(), | |
axis.ticks.length = unit(0,'mm'), | |
axis.title = element_text()) | |
p1 <- p0 %+% subset(d, facet < 2) | |
p2 <- p0 %+% subset(d, facet < 3) | |
p3 <- p0 %+% subset(d, facet < 4) | |
d2 <- data.frame(x=0,y=0,facet=1:3) | |
d2$subplots <- I(lapply(list(p1,p2,p3), ggplotGrob)) | |
p0 + geom_custom(data=d2, aes(data=subplots), grob_fun = identity)+ | |
xkcdaxis(c(-1,1),c(-1,1)) + | |
theme(strip.text = element_text(colour = "black")) + | |
theme(axis.text = element_blank(), | |
axis.ticks = element_blank()) + | |
labs(title='Facets',subtitle = 'facetted by number of facets') |
Author
baptiste
commented
Apr 1, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment