ggplot(tmp.d, aes(x = year, y = value, group = 1)) +įacet_wrap(facets = list("sector","subsector")) Which is plotted and faceted by sector and subsector. The data looks something like this: library(tidyverse) GridExtra::grid.arrange(p1, p2, nrow = 1, widths = c(2.I wish to facet a graph based on two factors, rename the facets using a combination of the two facet factor values, but preserve the order of the facets based on the levels in the original factors. P2 <- ggplot(subset(dta, grepl("^Wave", month)), aes(x = level, y = N)) +įacet_wrap(~month, ncol = 1, strip.position = "right") + Scale_y_continuous(expand = expansion(mult = c(0. P1 <- ggplot(subset(dta, !grepl("^Wave", month)), aes(x = level, y = N)) + I used a ratio of 2.5:1 which at least in my eye works fine. One drawback is that you have to fiddle around with plot widths so that the bars have the same width. Instead of fiddling around with the gtable one option would be to create the first two columns and the third columns as separate plots by filtering the data.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |