[Solved] Side by side box plot in ggplot2 [closed]


To plot two plots (or more) in one figure, you can use the facet_grid function in ggplot2 (http://docs.ggplot2.org/current/facet_grid.html for more info). You can choose on which trait the plots will be facetted by using a formula. On the left hand side you can mention rows (graphs under each other) and on the left hand side columns (graphs next to each other). extra input can for example decide whether your scales of your axes are changing with every graph or the same for every graph.

In your case, something like this would be how it works:

    ggplot(Data, aes(x=factor(Bin), y=Count)) + 
    geom_bar(colour = "black", stat = "identity", position = position_dodge()) +
    scale_fill_manual(values=c("#999999", "#000000")) +
    facet_grid(.~variable, scales = "fixed")

The last line of code does the work.

1

solved Side by side box plot in ggplot2 [closed]