Plotly for Ggplot2 is now entirely open source, free, and self-hosted
Learn more about why we've open sourced

Plotly ggplot2 Library


dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
qplot(carat, price, data=dsamp, colour=clarity)

Plotly graphs are interactive. Click on the legend entries to toggle traces, click and drag on the canvas to zoom, shift and click to pan.
p <- ggplot(data = d, aes(x = carat, y = price)) +
  geom_point(aes(text = paste("Clarity:", clarity)), size = 4) +
  geom_smooth(aes(colour = cut, fill = cut)) + facet_wrap(~ cut)

(gg <- ggplotly(p))

ggplotly works by serializing ggplot2 figures into plotly's universal graph JSON. See the ggplot2 → plotly test tables for current ggplot2 conversion coverage. Submit issues or contribute on rOpenSci.

Plotly's ggplot2 graphs are hosted online in your plotly account or drawn locally in RStudio. They can be embedded in HTML pages, Knitr documents, or Shiny apps. You don't need to use ggplot2 to use Plotly with R, you can also use Plotly's native R graphing library.

Documentation Examples

Basic Charts

Image Export & Retrieving Plots