I want to arrange multiple Violin Plots from different data sets using the
geom_violin next to each other like that:
library(ggplot2) library(gridExtra) library(carData) g1 <- ggplot(data = SLID, aes(x = wages, y = education)) + geom_violin(trim = FALSE) SLID_temp <- SLID[ - which(SLID$education %in% 10:15),] g2 <- ggplot(data = SLID_temp, aes(x = wages, y = education)) + geom_violin(trim = FALSE) grid.arrange(g1, g2)
The problem is, that the Violin Plots are not scaled the same. In the bottom picture it appears there are as many observations for education = 16.5 as there are for education = 12 in the upper plot. I want both of these Plots' width to be scaled the same (by the maximum observations of a token), so I can compare them better. For example a token with 100 observations in the upper plot should have the same width as a token with 100 observations in the bottom plot.
I have tried to do that using the scale options for
aes, but unfortunately that didn't work because it just scales on the given data. You can't give an argument for a relative width to an exact value. Does anyone have an idea how to scale the plots properly?!