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 (4) 9 Useful R Data Visualization Packages for Data Visualization | Mode (4)](https://i0.wp.com/images.ctfassets.net/fi0zmnwlsnja/1cBXRR6naLZxfJLVrxQMUm/db1a35a0d9f7cff3f28f6a0c6de54c56/r-data-viz-01.png?w=708&h=467&q=50&fm=png)
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
Lattice
![9 Useful R Data Visualization Packages for Data Visualization | Mode (6) 9 Useful R Data Visualization Packages for Data Visualization | Mode (6)](https://i0.wp.com/images.ctfassets.net/fi0zmnwlsnja/32sGcKJLNaaDZgkp825GW6/a4c2b412c659d927cafa0f765c655a95/r-data-viz-02.png?w=625&h=409&q=50&fm=png)
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 (8) 9 Useful R Data Visualization Packages for Data Visualization | Mode (8)](https://i0.wp.com/images.ctfassets.net/fi0zmnwlsnja/47gq57VhDldCyJT5TauU1G/47cf10a0ee4ca8b12416fc3c65d058ea/r-data-viz-03.png?w=854&h=811&q=50&fm=png)
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 (10) 9 Useful R Data Visualization Packages for Data Visualization | Mode (10)](https://i0.wp.com/images.ctfassets.net/fi0zmnwlsnja/50L8kxSQF0NXLu98WJMMuy/3d0de32348f2965eb4bccbd700db1535/r-data-viz-04.png?w=1300&h=430&q=50&fm=png)
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 (12) 9 Useful R Data Visualization Packages for Data Visualization | Mode (12)](https://i0.wp.com/images.ctfassets.net/fi0zmnwlsnja/2BUSPmei7aEw8Yb6UaSLYy/b9c6603764d0a2df4a3445875f679bed/r-data-viz-05.png?w=800&h=600&q=50&fm=png)
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
Plotly
![9 Useful R Data Visualization Packages for Data Visualization | Mode (14) 9 Useful R Data Visualization Packages for Data Visualization | Mode (14)](https://i0.wp.com/images.ctfassets.net/fi0zmnwlsnja/6RXbEAkVOFrrcRMAmkN8ZI/5a33dca58778d226150cf395dedbc081/r-data-viz-06.png?w=757&h=525&q=50&fm=png)
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
sunburstR
![9 Useful R Data Visualization Packages for Data Visualization | Mode (16) 9 Useful R Data Visualization Packages for Data Visualization | Mode (16)](https://i0.wp.com/images.ctfassets.net/fi0zmnwlsnja/6YlApjrVBqSjHaVuKHl7BD/b0284c19e38ba14e59472ab34adcd68a/r-data-viz-07.png?w=704&h=507&q=50&fm=png)
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 (18) 9 Useful R Data Visualization Packages for Data Visualization | Mode (18)](https://i0.wp.com/images.ctfassets.net/fi0zmnwlsnja/5sErctNpbabcXd3avYRS87/d561e6e71583eddc4d3a06de426a60a3/r-data-viz-08.png?w=348&h=326&q=50&fm=png)
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 (20) 9 Useful R Data Visualization Packages for Data Visualization | Mode (20)](https://i0.wp.com/images.ctfassets.net/fi0zmnwlsnja/2yNGqJR5Qzso6Lyp6QsdQJ/05dc7b9a42d1c4739155f00baf92b580/r-data-viz-09.png?w=660&h=373&q=50&fm=png)
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.