9 Useful R Data Visualization Packages for Data Visualization | Mode (2024)

Oct. 22 update: R has been upgraded to version 4.2.0 and popular R libraries have been updated in Mode’s notebook

If you've visited theCRAN repository of R packageslately, you might have noticed that the number of available packages has now topped a dizzying 18,000+. This means there are packages for practically any data visualization task you can imagine, fromvisualizing cancer genomestographing the action of a book.

For new R coders, or anyone looking to hone their R data viz chops, CRAN's repository may seem like an embarrassment of riches—there are so many data viz packages out there, it's hard to know where to start.

To provide one path through the labyrinth, we’re giving an overview of 9 useful interdisciplinary R data visualization packages.Mode R Notebookssupport three libraries on this list - ggplot2, Lattice, and Plotly - and more than 60 others that you can explore on ourNotebook support page.

  • ggplot2

  • Lattice

  • highcharter

  • Leaflet

  • RColorBrewer

  • Plotly

  • sunburstR

  • RGL

  • dygraphs

Learn more

Get a deeper dive of Mode's VisualizationsLearn how Mode's visualizations can help you tell stronger stories with your data.

ggplot2

9 Useful R Data Visualization Packages for Data Visualization | Mode (3)

9 Useful R Data Visualization Packages for Data Visualization | Mode (4)

Scatterplot (Hadley Wickham/Tidyverse)

While it's relatively easy to create standard plots in R, if you need to make a custom plot, things can get hairy fast. That's why ggplot2 was born: to make building custom plots easier.

In thewords of its creator, ggplot2 “takes care of many of the fiddly details that make plotting a hassle (like drawing legends) as well as providing a powerful model of graphics that makes it easy to produce complex multi-layered graphics.”

ggplot2 is based onThe Grammar of Graphics, a system for understanding graphics as composed of various layers that together create a complete plot. With ggplot2, you can, for instance, start building your plot with axes, then add points, then a line, a confidence interval, and so on.

The drawback of ggplot2 is that it may be slower than base R, and new programmers may find the learning curve to be a bit steep. Butfansargue that learning to master ggplot2 and (more generally) thetidyverseway of handling data pays huge dividends for any data scientist working in R.

Created by:Hadley Wickham, available inModeWhere to learn more:ggplot2

Try ggplot2 in Mode.

Lattice

9 Useful R Data Visualization Packages for Data Visualization | Mode (5)

9 Useful R Data Visualization Packages for Data Visualization | Mode (6)

Fitted models in panel functions (Deepayan Sarkar)

When you need to visualize multi-variate data, Lattice is your friend. Lattice is a system of plotting inspired byTrellis graphics. It helps you create tiled panels of plots to compare different values or subgroups of a given variable. (These tiled plots often end up looking like a garden trellis, as you can see above.)

Lattice was built using thegridpackage for its underlying implementation and it inherited a lot of grid's features. Since grid has subsequently been folded into base R, the logic of Lattice should feel familiar to many base R users.

For a deep dive into the differences between using ggplot2 and Lattice, check out this12-part seriesover at Learn R.

Created by:Deepayan Sarkar, available inModeWhere to learn more:Lattice

highcharter

9 Useful R Data Visualization Packages for Data Visualization | Mode (7)

9 Useful R Data Visualization Packages for Data Visualization | Mode (8)

Interactive choropleth map (Joshua Kunst)

Highcharter is an R wrapper forHighcharts, an interactive visualization library in JavaScript. Like its predecessor, highcharter featuresa powerful API.

Highcharter makes dynamic charting easy. It uses a single function, hchart(), to draw plots for all kinds of R object classes, from data frame to dendrogram to phylo. It also gives R coders a handy way to access the other popular Highcharts plot types,Highstock(for financial charting) andHighmaps(for schematic maps in web-based projects).

The package has easy-to-customize themes, along with built-in themes like “economist,” “financial times,” and “538,” in case you want to borrow a look for your chart from the pros.

Created by:Joshua KunstWhere to learn more:highcharter

Leaflet

9 Useful R Data Visualization Packages for Data Visualization | Mode (9)

9 Useful R Data Visualization Packages for Data Visualization | Mode (10)

GeoJSON map (RStudio)

Like highcharter, Leaflet for R is another charting package based on a hugely-popular JavaScript libraryof the same name.

Leaflet offers a lightweight but powerful way to build interactive maps, which you've probably seen in action (in their JS form) on sites ranging fromThe New York TimesandThe Washington PosttoGitHuband GIS specialists likeMapboxandCartoDB.

The R interface for Leaflet was developed using thehtmlwidgetsframework, which makes it easy to control and integrate Leaflet maps right in R Markdown documents (v2), RStudio, or Shiny apps.

Created by:Joe Cheng,Bhaskar Karambelkar,Yihui XieWhere to learn more:Leaflet for R

RColorBrewer

9 Useful R Data Visualization Packages for Data Visualization | Mode (11)

9 Useful R Data Visualization Packages for Data Visualization | Mode (12)

Diverging Color Scales (Plotly)

RColorBrewer makes it easy to take advantage of one of R's great strengths: manipulating colors in plots, graphs, and maps.

The package is based onCynthia Brewer’swork on the use of color in cartography (check outColorbrewerto learn more), and it lets you create nice-looking sequential, diverging, or qualitative color palettes. It also plays nicely with Plotly.

Created by:Erich NeuwirthWhere to learn more:RColorBrewer

Try RColorBrewer in Mode.

Plotly

9 Useful R Data Visualization Packages for Data Visualization | Mode (13)

9 Useful R Data Visualization Packages for Data Visualization | Mode (14)

Line plot (Plotly)

You might know Plotly as an online platform for data visualization, but did you also know you can access its capabilities from an R or Python Notebook?

Like highcharter, Plotly’s forte is making interactive plots, but it offers some charts you won’t find in most packages, likecontour plots,candlestick charts, and3D charts.

Created by:Plotly, available inModeWhere to learn more:Plotly

Try Plotly in Mode.

sunburstR

9 Useful R Data Visualization Packages for Data Visualization | Mode (15)

9 Useful R Data Visualization Packages for Data Visualization | Mode (16)

Football visualization with SunburstR (Mike Bostock)

Sunburst charts are great for visualizing data that describes sequences of events, fromsports datatouser flows through a product.

With SunburstR, you can build R charts just like thesunburst sequence visualizationscreated by Kerry Rodden ind3.js. The diagrams are interactive, giving viewers a powerful way to explore sequence data on their own.

Created by:Kent Russell,Kerry Rodden,Mike Bostock, andKevin WarneWhere to learn more:sunburstR

RGL

9 Useful R Data Visualization Packages for Data Visualization | Mode (17)

9 Useful R Data Visualization Packages for Data Visualization | Mode (18)

3D plot of iris data in RGL (Duncan Murdoch)

To create interactive 3D plots in R, check out RGL. Its logic is loosely modeled after base R graphics, but in three dimensions rather than two. Like Lattice, it's inspired by thegridpackage (though it's not technically compatible with it), so its methods should feel familiar to seasoned R coders.

RGL has lots of cool bells and whistles, including a variety of3D shapesto choose from,lighting effects, various “materials” for the objects, and even the ability to make ananimationof your 3D scene.

Created by:Daniel AdlerandDuncan MurdochWhere to learn more:rgl

dygraphs

9 Useful R Data Visualization Packages for Data Visualization | Mode (19)

9 Useful R Data Visualization Packages for Data Visualization | Mode (20)

Time series chart with range selector (RStudio)

This package provides an R interface fordygraphs, a fast, flexible JavaScript charting library for exploring time-series data sets. What's powerful about dygraphs is that it's interactive right out of the box, with default mouse-over labels, zooming, and panning. It's got lots of other nifty interactivity features, likesynchronizationor therange selectorshown above.

But dygraph's interactivity doesn't come at the expense of speed: it can handle huge datasets with millions of points without slowing its roll. And you can use RColorBrewer with dygraphs to choose a different color palette for your time series— check outthis exampleto see how.

Created by:Dan VanderkamandRStudioWhere to learn more:dygraphs for R

Now that you've taken our tour of 9 useful R data viz packages, you probably want to learn about some useless but fun R packages.Check out Ista Zahn's short list of 'Useless but Fun R Packages' here, and enjoy watching what the cow says, or having R tell your fortune.

If we've missed any of your favorite R data viz libraries in this short list, let us know! Tweet at us@ModeAnalytics.

Oct. 22 update: R has been upgraded to version 4.2.0 and popular R libraries have been updated in Mode’s notebook
9 Useful R Data Visualization Packages for Data Visualization | Mode (2024)
Top Articles
Latest Posts
Article information

Author: Cheryll Lueilwitz

Last Updated:

Views: 5930

Rating: 4.3 / 5 (54 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Cheryll Lueilwitz

Birthday: 1997-12-23

Address: 4653 O'Kon Hill, Lake Juanstad, AR 65469

Phone: +494124489301

Job: Marketing Representative

Hobby: Reading, Ice skating, Foraging, BASE jumping, Hiking, Skateboarding, Kayaking

Introduction: My name is Cheryll Lueilwitz, I am a sparkling, clean, super, lucky, joyous, outstanding, lucky person who loves writing and wants to share my knowledge and understanding with you.