A Professional Looking ggplot

Having worked in both R and Python for multiple years at this point.. I have come to the personal conclusion that R is superior when it comes to data visualization and exploration. That being said, base ggplot doesn’t bring visualization to the finish line. Exploration is quite fast in R, but when building a presentation, I don’t feel comfortable putting a base ggplot infront of a CEO. Rather, I find myself bringing an aggregated dataframe into Google Sheets, and from there, creating a clean and customized Google chart that I then have to copy into slides. This workflow is quite inefficient.

For example, say I’m building a presentation for Cameron Clayton, the CEO of The Weather Company. Having explored the data in R, I have the following figure available to add into a presentation.

This plot looks like I just scrapped it together while exploring the data (Precisely)! While polished charts seem like a waste of time by the logical side of my brain, they have time and time again shown to be important in building trust with the audience (trust in both myself and my numbers).

So instead, I take the time to bring the data into Google Sheets, clean it up, and paste it into Google Slides.

Given the inefficiency of this workflow – there are two questions that come to mind:

  1. Are there any ggplot formats or templates that look professional?
    • Are any companies using ggplot in their public facing work?

  2. How can I make my own template with my current employer’s color scheme?

Part 1. Is there a ggplot format or template that looks professional?

It’s important to call out that professionalism is subjective. Not everyone will agree on what is professional. This section reflects my personal opinions and input from professional colleagues.

To start out I want to answer the sub-question. Are there any companies using ggplot for public display? I was able to quickly find two:

These were two prominent examples I could find using ggplot publicly and I’m sure if I looked a little longer I could find more. That being said.. BBC, a news company, is publishing their ggplot charts for millions to see!

Using the bbplot package, I re-created the initial plot shown above.

Code Used

library(tidyverse)
library(bbplot)

df %>%
  ggplot(aes(x = time_of_day, y = Temperature)) +
  geom_line() +
  labs(title = 'Daily Temperature',
       subtitle = 'Limited to Feb 2, 2015 to Feb 4, 2015') + 
  bbc_style() +
  theme(plot.margin = margin(10, 50, 10, 20), axis.text.x = element_text(angle = 45, hjust = 1))+
  geom_hline(yintercept = 20, size = 1, colour="#333333") +
  geom_line(colour = "#1380A1", size = 1) +
  scale_x_datetime(date_labels = "%b %d, %I %p",breaks = scales::pretty_breaks(n = 7)) + 
  ylim(NA,25)

…Which I would say is a professional looking chart (and answers the primary question)! There are a few labeling improvements for this specific chart, but that is due to the nature of the data. In many cases, at Credit Karma I am interested in clicks/impressions over time so axis titles can be redundant.

Part 2. How can I make my own professional template that matches a given color scheme?

Rather than explain how to create a theme, I’ll point to some of the resources I found that provided an excellent walk through:

So with the resources listed above, I set out to create a theme that replicated the professional weather chart I would have created in Google Sheets.

Can you tell which plots were created in ggplot and which were created in google sheets?

What about now?

SPOILER ALERT!
In the top comparison it was the chart on the right, and in the bottom comparison it was the chart on the left. ggplot actually produced a smoother looking line than google sheets.


To conclude
It IS possible to build professional charts in ggplot, and organizations are already doing so! It just requires some time upfront to create or select and modify a theme to suit your needs. No more copying and pasting data, and as a result, a more efficient and reproducible workflow!

(Code to come)