grafify: Make 5 powerful ggplot2 graphs quickly with R

Written by Matt Dancho on June 15, 2021



The grafify package is a new R package that makes it easy to make 19-powerful ggplot2 graphs, ANOVAs, and comparison plots. I’ve been really enjoying it! In the next 10-minutes, we’ll learn how to make my 5 favorite grafify plots (with one line of code!):

  • Scatter-Bar (1), Scatter-Box (2), and Scatter-Violin (3) plots for plotting 2-variables
  • Scatter-Box 3D plots (4) for plotting 3-variables
  • BONUS: Before-and-After Plots (5) for showing State Change

This article was last updated on: February 15th, 2022.

R-Tips Weekly

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. 👇

Video Tutorial

Learn how to use the grafify package in our 7-minute YouTube video tutorial.

What you make in this R-Tip

grafify is a new R package for making great-looking ggplot2 graphs quickly in R. It has 19 plotting functions that simplify common ggplot graphs and provide color-blind friendly themes. By the end of the tutorial, you’ll make:

  1. Scatter Bar SD
  2. Scatter Box SD
  3. Scatter Violin SD
  4. Scatter Box 3D
  5. BONUS: Before and After Plots!!!

Image Credit: grafify package

Thank You Developers.

Before we move on, please recognize that the grafify package was generously built and maintained with many hours of work by Avinash R. Shenoy. Thank you for all that you do!

The grafify Tutorial

The grafify package extends ggplot2 by adding several simplified plotting functions. Let’s explore the package by making 5 powerful plots (with one line of code)!

Load the Libraries and Data

First, run this code to:

  1. Load Libraries: Load grafify and tidyverse.
  2. Import Data: We’re using the mpg dataset that comes with ggplot2.

Get the code.

Plot 1: Scatterbar SD Plot

First, we can make a Scatterbar Plot that shows the data points along with error bars at a standard deviation. Simply use plot_scatterbar_sd().

Get the code.

Plot 2: Scatterbox Plot

Next, we can make a Scatterbox Plot that shows a custom boxplot / jitter plot combination. I’ve added a jitter point to show the distribution. Simply use plot_scatterbox().

Get the code.

Plot 3: Dotviolin Plot

Next, we can make a Dotviolin Plot that shows a custom violin plot / dotplot combination. Simply use plot_dotviolin().

Get the code.

Plot 4: Scatterbox 3D Plot

Next, we can make a 3D Scatterbox Plot that shows three variables using boxplot / jitter plot combination. This is great for drilling into multiple categories. Simply use plot_3d_scatterbox().

Get the code.

BONUS: Plot 5 - Before-After Plot

As a super cool bonus, we can make a Before-After Plot that shows changes between two states (in this case how various models changed in MPG Fuel Efficiency from 1999 to 2008). This is great for comparing two states. Simply use plot_befafter_colors().

Get the code.

We can see that most vehicles are improving in MPG from 1999 to 2008. However, there are a few that are going down. Most notably is the New Beetle going from 35MPG to about 27MPG, a decline of -23%.

Recap

We learned how to make 5 powerful plots using the grafify package. 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:

  1. mmtable2: ggplot2 for tables
  2. ggdist: Make a Raincloud Plot to Visualize Distribution in ggplot2
  3. ggside: Plot linear regression with marginal distributions
  4. DataEditR: Interactive Data Editing in R
  5. openxlsx: How to Automate Excel in R
  6. officer: How to Automate PowerPoint in R
  7. DataExplorer: Fast EDA in R
  8. esquisse: Interactive ggplot2 builder
  9. gghalves: Half-plots with ggplot2
  10. rmarkdown: How to Automate PDF Reporting
  11. patchwork: How to combine multiple ggplots
  12. Geospatial Map Visualizations in R

Want these tips every week? Join R-Tips Weekly.