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.
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.
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:
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.
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
protected by Community♦ Dec 3 '14 at 19:12
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?