Compare multiple ggplots side by side as done in the examples of ggplot2 book

84 views
Skip to first unread message

Santanu Pramanik

unread,
Aug 12, 2020, 5:12:07 AM8/12/20
to ggplot2
Hi all,
I am new to the group. I am thoroughly enjoying reading two books by Hadley Wickham; ggplot2 and R for data science. I have a basic question. How can one compare multiple ggplots side by side as done in the examples of ggplot2 book? When I try the codes of the book, I get to see one plot at a time, although in the book the plots appear side by side. The par(mfrow=c(1,2)) function of R does not seem to work.
Any suggestion would be appreciated.
Santanu

Ben Bolker

unread,
Aug 12, 2020, 7:39:20 AM8/12/20
to Santanu Pramanik, ggplot2
Check out the cowplot package

--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ggplot2/b7c34ca3-3c82-4532-bbcd-a14eaeefd8d0n%40googlegroups.com.

Brandon Hurr

unread,
Aug 12, 2020, 7:48:25 AM8/12/20
to Ben Bolker, Santanu Pramanik, ggplot2
Thomas’s patchwork package also does similar things. 

Manuel Gutierrez

unread,
Aug 12, 2020, 8:20:13 AM8/12/20
to Ben Bolker, Santanu Pramanik, ggplot2

Can you refer to a specific page and the book?

 

The only side-by-side plots I recall are done by using “facets”. If there is a way of doing what you are suggesting I’d like to know.

 

Manuel

Lorenzo Crippa

unread,
Aug 12, 2020, 8:25:16 AM8/12/20
to Manuel Gutierrez, Ben Bolker, Santanu Pramanik, ggplot2
You can also check out gridExtra as a package that allows you to combine ggplot2 objects and display them in rows or columns. Although by my experience cowplot works better, it lets you align plots’ axes (something I often need and I’ve never understood how to do with gridExtra).

Lorenzo

Reply all
Reply to author
Forward
0 new messages