I am trying to make the width of all bars in the following plot equal. Can anybody help me? is it possible? or is there any way to plot this data?
library(ggplot2)
dat <- data.frame(x = c('I','I','I','I','II','II'),
y = LETTERS[1:6],
z = abs(rnorm(6)))
ggplot(dat, aes(y,z))+
geom_bar(stat = "identity") +
facet_wrap(~x,scales="free")
I also tried using arguments size
and width
inside the geom_bar
but its not working.
Really the problem is that each of the facet panels is being forced to be the same size and then the plot inside expands to fill all the available room. With facet_grid
you can adjust the space for each facet panel (but you cannot seem to do this with facet_wrap
). Try
ggplot(dat, aes(y,z))+
geom_bar(stat = "identity") +
facet_grid(~x,scales="free", space="free_x")
which gives me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With