How I analyze 100+ ggplots at once
Written by Matt Dancho
Visualizing big data is next to impossible. As soon as I have 12 plots, that’s where my ability to use native ggplot suffers. That is until I found
trelliscopejs is like
ggplot2 faceting on steroids. This may seem crazy, but the benefit is that when you have 20, 30, or even 100+ plots you need to analyze,
trelliscopejs is the solution!
And, I’m going to get you up and running with
trelliscopejs in under 5-minutes:
- I’ll teach you how to make 20+ ggplot facets using trelliscopejs
- BONUS: I’ll not only show you how to make static ggplots, but I’ll even show you how to use the plotly integration for interactivity
This article is part of R-Tips Weekly, a weekly video tutorial that shows you step-by-step how to do common R coding tasks.
Here are the links to get set up. 👇
Learn how to use the
trelliscopejs package in my 5-minute YouTube video tutorial.
What you make in this R-Tip
By the end of this tutorial, you’ll make the 20+ ggplots for exposing insights in your big data.
Analyzing 20+ ggplots (made with
Thank You Developers.
Before we move on, please recognize that
trelliscopejs was developed by Ryan Hafen (follow Ryan on Twitter). Thank you for everything you do!
Also, the full documentation for trelliscopejs can be accessed here.
Let’s dive into using
trelliscopejs so we can analyze 100+ ggplots.
Step 1: Load the Libraries and Data
First, run this code to:
- Load Libraries: Load
- Import Data: We’re using the
mpgdataset that comes with
Our data looks like this. We want to understand how Highway Fuel Economy (
hwy) varies with
displ (engine size) but we want to see if there is any differences between
The mpg dataset
Step 2: Make a ggplot
Next, let’s make a basic ggplot of fuel economy vs engine displacement.
This produces the following plot of
Our basic ggplot
Step 3: Apply the trelliscopejs magic!
Listen, I’m telling you this next part is straight-up magic!
Seriously, I now use this simple trick to analyze 100+ ggplots at once.
- Use the
- This replaces a
- And makes 100’s of ggplots (as many as your heart desires)
- In this case, we facet by
manufacturerand end up with 15 plots to analyze.
The result is the trelliscope plot with 15 ggplots by manufacturer.
We've transformed our ggplot into a faceted trelliscope with 15 plots by manufacturer
Step 4: Customize the Trelliscopejs
This is really cool!! You can add additional labels like max/min displacement by plot.
Customize the trelliscope with labels & filters
BONUS: Make your trelliscope interactive!!!
If you thought you were done…
We’re just gettin’ started!
THIS is the magic of trelliscope!!
- Add interactivity with the Plotly integration inside of
- Simply add
as_plotly = TRUE
Check out the interactivity from plotly!!
Interactivity with the plotly-trelliscopejs integration
We learned how to use the
trelliscopejs library to not only create 100’s of static ggplots but create 100’s of interactive plotly plots. Great work! But, there’s a lot more to becoming a data scientist.
If you’d like to become a data scientist (and have an awesome career, improve your quality of life, enjoy your job, and all the fun that comes along), then I can help with that.
Step 1: Watch my Free 40-Minute Webinar
Learning data science on your own is hard. I know because IT TOOK ME 5-YEARS to feel confident.
AND, I don’t want it to take that long for you.
So, I put together a FREE 40-minute webinar (a masterclass) that provides a roadmap for what worked for me.
Literally 5-years of learning, consolidated into 40-minutes. It’s jammed packed with value. I wish I saw this when I was starting… It would have made a huge difference.
Step 2: Take action
For my action-takers, if you are ready to take your skills to the next level and DON’T want to wait 5-years to learn data science for business, AND you want a career you love that earns you $100,000+ salary (plus bonuses), and you’d like someone to help you do this in UNDER 6-MONTHS or less….
Then I can help with that too. There’s a link in the FREE 40-minute webinar for a special price (because you are special!) and taking that action will kickstart your journey with me in your corner.
Get ready. The ride is wild. And the destination is AMAZING!
👇 Top R-Tips Tutorials you might like:
- mmtable2: ggplot2 for tables
- ggdist: Make a Raincloud Plot to Visualize Distribution in ggplot2
- ggside: Plot linear regression with marginal distributions
- DataEditR: Interactive Data Editing in R
- openxlsx: How to Automate Excel in R
- officer: How to Automate PowerPoint in R
- DataExplorer: Fast EDA in R
- esquisse: Interactive ggplot2 builder
- gghalves: Half-plots with ggplot2
- rmarkdown: How to Automate PDF Reporting
- patchwork: How to combine multiple ggplots
- Geospatial Map Visualizations in R
Want these tips every week? Join R-Tips Weekly.