Introduction

This tutorial explores how to use the Esquisse package in R to create ggplot2-style data visualizations without extensive knowledge of ggplot2 or R/R Studio.


Content Overview

Specifically, the tutorial will explain and demonstrate how to access the Esquisse package and how to utilize some of the data visualization functions that it offers, as well as how to export completed data visualizations for use in other programs.


Why You Should Care

Being able to leverage Esquisse is valuable because it is often necessary to work as a member of a team including people with varied skill-sets. If not all members of the team are equally skilled in working with R Studio and ggplot2, it may be useful to be able to offer a user-friendly interface, similar to Tableau, that allows for interacting with the data without extensive knowledge of R Studio. Further, Esquisse allows for data visualizations to be shared in other programs (as images or .pdfs, etc.), which helps make utilization and presentation simple.


Learning Objectives

Specifically, you’ll learn how to:

  1. Launch the Esquisse addin and load data.
  2. Understand the Esquisse addin pop-up interface.
  3. Use Esquisse’s drag-and-drop functionality to create data visualizations.
  4. Get data visualizations presentation-ready and export them to other tools for distribution and wider use.



Using Esquisse

Here, we’ll demonstrate how to access the Esquisse addin, which is the tool through which the package can be used, before demonstrating some of the data visualizations that it can create.

This tutorial is based on those provided by CRAN, dreamRs on Github, and Appsilon.


Launching Esquisse

To start, the first step is to install the Esquisse package and load it in R Studio. To do this, the following code should be copied into a new R Script window, as Esquisse cannot run in RMarkdown.

# Installing Package
install.packages(esquisse)

#Loading the Installed Package
library(esquisse)

Then, the Esquisse addin must be launched in RStudio. It will appear as a pop-up window and the data being used may be called up at the same time. For this example, using the data from the mtcars dataset, the addin can be accessed by copying the following code into the R Script window in which the package is loaded:

# Launching the Addin and Calling the Data
esquisse::esquisser(mtcars)

In the event that data is not loaded at the same time that the addin is launched, it is also possible to do so by using the “Import Data” button resembling a cylinder at the top left of the addin, which will launch a pop-up window from which data may be added.

Import Data and Show Data Buttons
Import Data and Show Data Buttons


Import Data Pop-Up
Import Data Pop-Up


Once the the Esquisse addin has launched and the data is loaded, anyone, even those with little to no knowledge of R, R Studio, or ggplot2 can start manipulating the data to create data visualizations. It is also possible to inspect the data by using the “Show Data” button, which resembles a spreadsheet, next to the “Import Data” button at the top left of the addin.

Show Data Pop-Up
Show Data Pop-Up


The Esquisse Interface

The main screen of the Esquisse addin features a drag-and-drop menu that allows any user to create data visualizations.

Esquisse Addin Main Screen
Esquisse Addin Main Screen


The addin lists the type of graph being made, defaulting to “auto” near the top left of the screen, just below the “Import Data” button. This can be changed simply by clicking on the arrow and selecting a new type.

Next to the graph type menu are the variables that are included in the dataset, and below those are listed the various items that the user can manipulate, including the x-axis variable, the y-axis variable, fill color, size, group, and facet, which appear as buckets that dataset variables can be dropped into.


Creating Basic Data Visualizations

To actually create a graph, the user can choose any variable contained within the mtcars dataset, for instance, the number of cylinders (cyl), and drop that into the bucket labeled “X,” for the x-axis. By doing this, the Esquisse package automatically creates a histogram displaying the number of cars (count) with a given number of cylinders.

Histogram of Cylinders
Histogram of Cylinders


If adding a second variable to the graph, such as miles per gallon (mpg), to the “Y” bucket for the y-axis, the graph automatically becomes a point (scatterplot) graph, showing a single dot for each individual vehicle.

Point Graph of Miles per Gallon by Number of Cyclinders
Point Graph of Miles per Gallon by Number of Cyclinders


Once the user has created their basic graph, they can also add a title and axis labels, just as they might in Excel or Sheets. In Esquisse, this option can be accessed by clicking on the “Labels & Title” menu at the bottom left, from which axis labels, title, subtitle, and captions can all be edited, including their locations and relative sizes.

Updating Labels & Title
Updating Labels & Title

Getting Visualizations Presentation-Ready

Once a basic graph is prepared, it’s time to think about how to turn it into something that can actually be used. In order to get the graph presentation ready, the user should think about how to add relevant complexity to the graph. With the mtcars data set, we can see from inspecting the data that not only are the number of cylinders a car has negatively correlated with gas mileage (mpg), meaning that mpg generally decreases as the number of cylinders increases, but that engine horsepower and displacement are related to the number of cylinders and the gas mileage as well (both increase as the number of cylinders increases and the gas mileage decreases). By dragging and dropping horsepower (hp) into the color bucket and displacement (disp) into the size bucket, or vice versa, the graph can display all of those relationships simultaneously. When additional variable buckets are used, they automatically appear in the “Labels & Title” menu so that legend labels can be updated in the same way that the axis labels are.

Adding Variables for Relevant Complexity
Adding Variables for Relevant Complexity


To increase the visual interest of the graph, the user can also access the “Appearance” menu at the bottom center, which from they can change the color of the data points, the point symbols, the theme, and the legend position, depending on their needs.

Adding Visual Interest
Adding Visual Interest


Another option is to make the story that the graph tells even clearer, using the “Plot Options” menu, second from the left at the bottom of the addin. This option allows for the addition of a smooth line and for the axes to be manipulated by adjusting the limits, transforming the units, or flipping the coordinates.

Using Plot Options
Using Plot Options


Once the graph is in its finished form, there are two options for sharing it. The first, for R-users, is to access the “Code” menu at the bottom right of the addin, and copy the code into an R Markdown document, which provides the R code without needing to manually write it. Do to this, it is important to make sure that both the ggplot2 package and the mtcars dataset are availabe in the R Markdown document.

Accessing ggplot2 Code
Accessing ggplot2 Code


Actually running the provided code will render the graph in the R Markdown file.

# Loading ggplot2 and the mtcars Dataset

library(ggplot2)
dat <- (mtcars)

# Placing the Graph in an R Markdown Document

ggplot(dat) +
  aes(x = cyl, y = mpg, colour = hp, size = disp) +
  geom_point(shape = "circle") +
  geom_smooth(span = 0.75) +
  scale_color_viridis_c(option = "plasma", direction = -1) +
  labs(
    x = "Cylinders (cyl)",
    y = "Miles per Gallon (mpg)",
    title = "Miles per Gallon by Number of Cylinders",
    subtitle = "Accounting for Horsepower and Displacement",
    caption = "Data From the mtcars Dataset",
    color = "Horsepower (hp)",
    size = "Displacement (cu. in.)"
  ) +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 16L,
    face = "bold",
    hjust = 0.5),
    plot.subtitle = element_text(size = 14L,
    face = "italic",
    hjust = 0.5),
    plot.caption = element_text(size = 14L,
    face = "italic",
    hjust = 0.5)
  )


The second option for sharing the completed graph is to export it to another file type. From the main page of the addin, the user should click on the download symbol underneath the variable buckets at the right-hand side of the screen. If the graph is exactly as it should be and the user know what file type they want to use, they can select that file type directly from this menu. If further adjustments to the the appears are needed, they user can select “More options.”

Downloading the Graph
Downloading the Graph


When “More options” is selected, an “Export chart” window opens, from which the export can be named, image dimensions adjusted, and the file exported to the preferred format. Exporting to, for instance, a JPEG file, will render the graph as an image that can be shared and used as needed, such as by inserting it into a presentation format to be shared with a wider audience.

Exporting to Another File Type
Exporting to Another File Type



Further Resources

Learn more about the Esquisse package and how it works with the following:




Works Cited

This tutorial references and cites the following sources:


  • Comprehensive R Archive Network (CRAN). (2024, January 10). Explore and Visualize Your Data Interactively [R package esquisse version 1.2.0]. CRAN

  • Comprehensive R Archive Network (CRAN). (n.d.). Get started with esquisse. CRAN

  • Explore and visualize your data interactively. (n.d.). dreamRs on Github

  • Radečić, D. (2023b, August 21). R Esquisse: How to explore data in R through a tableau-like Drag-and-Drop Interface. Appsilon