Rusers focusing on dashboards or data visualizations are inherently dependent on the ggplot2 package. It is the versatile package for plotting data based on the Grammar of Graphics. The idea behind it uses semantics like aesthetics, scales, and layers to build the visualization.

Here is a goto tutorial series for people who are looking for quick solutions with limited time on hand to polish their visualizations. This is a four-part series dealing with plotting different styled plots using ggplot2 packages and other add-on packages. These tutorials are as follows:

  1. Scatter and box plots
  2. Bar plots, Histograms, and Density plots
  3. Circular plots (pie charts, spider plots, and bar plots)
  4. theme(): create your own theme() for increased workflow

In this tutorial, we will work on creating scatter and box plots. After this tutorial, you will be able to make much better visualizations as shown below.

Dataset and packages

For this tutorial, we will be using the global temperature change recorded for the years between 1961 to 2019 for most of the countries. The dataset can be downloaded from here. For the time being, we will focus on the temperature change that occurred in India.

The packages used for this tutorial are:

tidyverse: used for all the manipulations to get the dataset in the right format for plotting purposes

ggplot2: for plotting the data

ggforce: control the width of the jitter using the density distribution of data

patchwork: combining different plots to make a single image

Once the packages are loaded and the data is processed according to the requirements, we are ready to create our first plot. We will start with the scatter plot and then move to the box plot.

#ggplot2 #r #data-visualization #data-science

Master data visualization with ggplot2: scatter and box plots
1.90 GEEK