Choosing between qplot() and ggplot() in ggplot2 [closed]

As for me, if both qplot and ggplot are available, the criterion depends on whether data is stored in data.frame or separate variables.

x<-1:10
y<-rnorm(10)

qplot(x,y, geom="line") # I will use this
ggplot(data.frame(x,y), aes(x,y)) + geom_line() # verbose

d <- data.frame(x, y)

qplot(x, y, data=d, geom="line") 
ggplot(d, aes(x,y)) + geom_line() # I will use this

Of course, more complex plots require ggplot(), and I usually store data in data.frame, so in my experience, I rarely use qplot.

And it sounds good to always use ggplot(). While qplot saves typing, you lose a lot of functionalities.


I am new to R but just thought of sharing this.

 a <- c(1,2,3)

 b <- c(2,3,4)

 x <- qplot(a,b)

 y <- ggplot(data.frame(a,b), aes(a,b)) +geom_line()

If i change the value of the variables a and b and then plot x, it will take into account the changed values where as y would not. So while scripting it would be good to use ggplot as if you use qplot all the graphs will be equal to the latest provided references to qplot.


I think it depends on how often and for what purpose you intend to use ggplot2.

I mainly use ggplot2 for graphics in publications. This means that I tend to need the more advanced features and so I have never bothered to learn about qplot. Also, since I have around four publications a year, I'm not using ggplot2 enough to be really comfortable with the syntax and so concentrating on a single aspect seems optimal.

However, if you get new data sets each week, then you are probably interested in quickly exploring the data sets and producing good quality plot. In this case, learn both. You will get enough practice with the syntax and will (eventually) save time with qplot.