ggplot2 improves the graphics drawn with R. A (very) short adaptation time is needed to find how to make graphs equivalent to the ones of *graphics*.

For example, to draw the curve of a function, there is no function similar to `curve()`

. You have to use `qplot()`

by setting the `stat`

and `geom`

arguments as shown below.

First, the ggplot2 package must be installed.

install.packages("ggplot2")

Here, I plot the probability density function of the gamma distribution with parameters /(/alpha = 1/) and /(/beta = 1/) between 1 and 10:

require("ggplot2")
qplot(1:10, stat = "function", geom = "line",
fun = function(x) dgamma(x, shape = 1))

With `curve()`

:

curve(dgamma(x, shape = 1), from = 1, to = 10)

The ggplot2 community is fairly active and the web searches with the keyword “ggplot2″ almost always lead to relevant results.

*Related*

To

**leave a comment** for the author, please follow the link and comment on their blog:

** Rronan » R**.

R-bloggers.com offers

**daily e-mail updates** about

R news and

tutorials on topics such as: visualization (

ggplot2,

Boxplots,

maps,

animation), programming (

RStudio,

Sweave,

LaTeX,

SQL,

Eclipse,

git,

hadoop,

Web Scraping) statistics (

regression,

PCA,

time series,

trading) and more...

If you got this far, why not

__subscribe for updates__ from the site? Choose your flavor:

e-mail,

twitter,

RSS, or

facebook...

**Tags:** curve, dgamma, ggplot2, qplot, R