The Uses and Differences between ggplot2 and Plotly for Data Visualization with R

Image courtesy from Alexander Sinn from Unsplash

Introduction

  1. ggplot2, and
  2. Plotly.

Why use Plotly?

  • Plotly can effortlessly create interactive and publication-like grade graphs and charts,
  • Plotly’s interactive data visualization graphs and charts include key object types required by stakeholders, such as histogram, line plot, box plot, scatter plot, area plot, bar plot, etc.
  • Plotly supports end-user interactive plotting in broadly used programming tools and IDE’s, such as R, Python, JavaScript, and MATLAB.

Why use ggplot2?

  • ggplot2 plot works best with data that is stored in the ‘long’ format. In other words, where the data is stored within a column for every variable, and a row is used for every observation,
  • Well formulated and structured data will save data scientists loads of time when constructing data figures with ggplot2,
  • Building plots with ggplot2 is normally an iterative or repeatable process. One start’s by defining the dataset to use, the layout of the axes, and then a geometric function is tried and tested to represent the data. Once these items are approved, alpha transparency can be added to the figure to avoid overplotting or data crowding. Different plotting colours are also introduced during this development stage.

ggplot2 and Plotly — What are their Key Differences?

  • Plotly is naturally interactive, whereas ggplot2 requires a tooltip add-on to become interactive,
  • Plotly has an online user-friendly interactive graph editor,
  • Plotly is greatly enhanced using open-source interfaces or Python, R, MATLAB, and React, whereas ggplot2 is a data visualization package designed for the programming language R,
  • Despite Plotly’s availability with programming languages, it is nowhere nearly as customizable as ggplot2 is,
  • The data science community have reported multiple bugs and issues with Plotly’s axis labels overlapping tick marks during interactive sessions,
  • Plotly can present some excellent interactivity opportunities with minimal start-up costs and effort compared to ggplot2,
  • ggplot2 is considered a general method for data visualization, which inspects and distributes graphs into semantic components using scales and layers,
  • Working with large datasets and data frames, Plotly has been reported to be much slower rendering the data as compared to ggplot2.
Image courtesy from ThisisEngineering RAEng from Unsplash

Conclusion

--

--

I am a freelance writer on all things Business, DIY, Sport, Technology, IT and Management.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Paul Chambiras

I am a freelance writer on all things Business, DIY, Sport, Technology, IT and Management.