For plotting with R, should I learn ggplot2 or ggvis? I don't necessarily want to learn both if one of them is superior in any regard. Why R community keeps creating new packages with overlapping functionalities? The introduction blog post does not mention a word why ggvis is created given that a sophisticated plotting package ggplot2 already exists.

  • 5
    $\begingroup$ ggvis is an entirely different kettle of fish. The real alternative is between ggplot and lattice. $\endgroup$
    – Gala
    Sep 29 '14 at 12:37
  • 1
    $\begingroup$ I think the answer depends on what you're after. If you're looking for static advanced plots, you'll want to learn ggplot2. For web visualization, consider ggvis. $\endgroup$ Nov 23 '14 at 8:28

Start with ggplot2. It creates static plots.

Apart from static plots, ggvis can be used for creating interactive plots as well. Once you have learned the syntax of ggplot2, then the syntax for adding interactivity to create ggivs plots will follow naturally.

  • 4
    $\begingroup$ This is inaccurate (maybe it was accurate at the time of writing). ggvis can definitely be used to create static plots. The fact that it also allows for interactive plots is a feature, not a limitation. One simple example of a static plot: library('ggvis'); mtcars %>% ggvis(~wt, ~mpg) %>% layer_points(fill = ~factor(cyl)) $\endgroup$
    – airstrike
    Mar 1 '16 at 20:45

I want to expand a bit on Dianne Cook's answer. As she said, ggplot2 is for creating static plots, ggvis is for interactive plots. There are a bunch of implications to that:

File Type ggvis output is HTML including CSS and javascript files. ggvis does not naturally output ordinary image files. ggplot2 outputs ordinary images, which can then be embedded in HTML or pdf or gif or e-mailed, or whatever else. ggvis, if you want to e-mail the file, you're zipping-up a directory of HTML files to be viewed in a browser.

Animation A consequence of that is that if you want to create an animation, you can make the frames in ggplot2 and merge them, but there's no natural way to do this with ggvis. ggvis acting interactively will animate "live," but these are different kinds of animation. If there's more going on per frame than ggvis can process, you can't work around that (at least in a natural way) by generating the images and making the movie in the background. Similarly, the user can't download a movie or gif file from ggvis to replay.

Right now in my current project, I switched from ggplot2 to ggvis because ggplot2 was far too slow for animating interactively. But, I'd also like the user, after toying with settings, to be able to click "go" and download a full-speed, smooth-animation movie of what they did. I haven't figured out how to do this using ggvis, but it would be cake using ggplot2.

Speed ggvis is much, much, much faster than ggplot2, especially when changing data. Each ggplot2 plot has a second or a few of delay. ggvis has a second or so when you first create the plot, after that changing the data is seamless -- ggvis can be "reactively" linked to data so it updates itself whenever the data changes. With ggplot2, the whole plot is going to get redrawn.

Style & Appearance ggplot2 plots seem a bit nicer, at first glance, than ggvis plots. ggplot2 plots are quite elegant. ggvis plots are simpler, but they are growing on me. There are also extensions for ggplot2, such as the xkcd and wesanderson packages, where there's no analog for ggvis. ggplot2 plots all look like they were made by the same person (the author of ggplot2) and that gets tired after a while.

Completeness There are plot types you can create in ggplot2 that ggvis doesn't support, at least so far. For example there's no "rug" plot element in ggvis. I've seen one or two choropleths that were made with ggvis, but there's no natural built-in support yet. ggplot2 has polar coordinates (i.e., pie charts), ggvis does not. Also missing from ggvis (and available either in ggplot2 or in a ggplot2 extension): boxplots; contour plots; natural heatmaps; natural correlation charts; dotplots; violin plots; network plots; dendrograms. Of course I'm sure some very clever folks can create all these in ggvis, but I'm not that clever.

Annotations ggplot2 has a very nice, perhaps under-utilized, annotation framework. ggvis does not.

Subplots & Facets ggplot2 has a very nice, but perhaps rather limited, "faceting" feature. You can also combine multiple ggplot2 plots using the grid package. As of now, you cannot do either with ggvis. ggvis plots cannot be combined into a single image (because they aren't images, they're "live" webpages), and it doesn't support any kind of faceting or subplotting. This is supposed to be in the pipeline.

Visual Flexibility ggplot2 wants every plot to look the same, which means like the author prefers stylistically. There is no way, for example, to have a plot with multiple y axes in ggplot2. ggvis can. ggvis is a lot more flexible than ggplot2. Its far easier to do things like hide legends, combine multiple legends into one, use different scales for different things on the same plot, etc.

Deep Customizability If you want to create, say, a new clever scale, its not too hard to do that in ggplot2 (although it is pretty confusing). There just doesn't seem to be a way to do a lot of that in ggvis. Maybe its just not-yet.

Time Series ggplot2 does not like to plot time series. It can, but it doesn't want to. Actually neither of them want to; both insist on being fed data in a data.frame, and they can't handle xts or zoo objects. They don't have built-in features for slicing a time series either. But ggvis doesn't fight back against the time series as hard as ggplot2. That's partly because its so fast to update the data in a ggvis plot, I suppose. If you want to plot a timeseries you're going to have to beat either into submission, but ggvis is a lot less passive-aggressive about it.

Are They The Same Syntax? Sort of... There's a lot in common between them, and learning to think in the style of one will help to adapt to the style of the other. In particular, both are designed so all the plotting calls are piped into each other all on a single line of code. The primary advantage of this is it makes debugging and profiling really hard, and basically renders the debugging/profiling features in things like Rstudio useless. Other than that, they're syntactically quite different. Some things that are hard in ggplot2 are easy in ggvis. Some thing that are easy in ggplot2 are impossible in ggvis. And vice versa. (I have a bit of a preference for the way ggvis does things, which I find easier to understand.)

Bugs ggvis still has quite a few. Sometimes it behaves just oddly. Sometimes, though, plots randomly disappear for reasons that take hours to work-around and make very little sense. The developers admit this freely, ggvis is not production-ready yet. If you deal with any complexity, you will discover they aren't kidding.

The Bottom Line: Learning intermediate plotting in each takes about 16 hours. So, realistically, you're probably gonna learn both.

  • 1
    $\begingroup$ Great comparison $\endgroup$
    – skan
    Aug 15 '15 at 14:31
  • $\begingroup$ What is faster ggvis or lattice or rgl? (for large datasets) $\endgroup$
    – skan
    Oct 31 '15 at 12:05
  • $\begingroup$ +1 fantastic write up. I agree with everything in here based on my experiences with both so far. $\endgroup$ Apr 19 '16 at 15:38
  • $\begingroup$ Hello, What about ggvis vs rcharts? $\endgroup$
    – skan
    Jun 7 '16 at 15:38
  • $\begingroup$ TIME SERIES: ggplot2 definitively win with the expansion ggfortify. See this excellent documentation about it: rpubs.com/sinhrks/basics. $\endgroup$
    – Archimede
    Feb 3 '17 at 12:46

I think the message appearing after library(ggvis) is self explanatory:

The ggvis API is currently rapidly evolving. We strongly recommend that you do not rely on this for production, but feel free to explore. If you encounter a clear bug, please file a minimal reproducible example at https://github.com/rstudio/ggvis/issues. For questions and other discussion, please use https://groups.google.com/group/ggvis.

Compared to ggplot2 ggvis still lacks some features and polish (no way to add title to a graph for example, axis titles overlapping with tick labels, and there are more, facetting is not supported, etc.) On the other hand the ggvis syntax feels a bit cleaner, and interactivity is really awesome.

From my own experience ggvis is a must if you are building a shiny app. Then the benefits of having a web and R friendly graph plotting engine heavily outweigh any deficiencies it currently has.

If you want to do static graphs for data exploration, then ggplot2 is a mature library with lots of cool features and with a healthy community of users and lots of resources to learn from.

The philosophy behind both the packages is similar, so the skills can be transfered quite easily from one package to another.


The R community keeps coming up with new (and often overlapping) packages for a variety of reasons:

1) Someone wants to change something or add something that isn't available in an existing package, but much of it overlaps (hence, many packages that do regression)

2) Someone writes a package as an assignment

3) Writing packages is fun (if you like that sort of thing)

4) They don't know the original package exists

  • 11
    $\begingroup$ Regarding the specific example and your point 4: ggvis is authored by the same people as ggplot2. The important point here is that use of ggplot2 is so wide-spread that it has become impossible to implement changes without breaking a lot of existing code/dependent packages. $\endgroup$
    – Roland
    Sep 29 '14 at 7:54
  • 1
    $\begingroup$ Is this kind of reinvention of preexisting package destined to happen just like economic recessions in capitalism societies? $\endgroup$
    – qazwsx
    Sep 29 '14 at 16:42
  • 2
    $\begingroup$ @Peter: As an outsider to R this seems to me like fair comment but (most unusually) you don't answer the question! $\endgroup$
    – Nick Cox
    Oct 2 '14 at 10:10
  • $\begingroup$ @NickCox I answered one of the questions that are in the question. :-). $\endgroup$
    – Peter Flom
    Oct 2 '14 at 11:23
  • 1
    $\begingroup$ @Peter Very fair point. A cross reference to stats.stackexchange.com/questions/58966/… is I think pertinent therefore. $\endgroup$
    – Nick Cox
    Oct 2 '14 at 11:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.