• Open Source.
    These libraries are free forever. Your Pro plan helps keep them top notch.
  • Share Online.
    Share charts, dashboards, Jupyter notebooks, and presentations through our enterprise-grade cloud.
  • Engineering Support.
    Get instant chat support from our awesome engineering team.
Show Sidebar Hide Sidebar

Plotly ggplot2 Library

ggplot2 is a graphing library for R. Use ggplot2 with Plotly to create interactive, online ggplot2 charts with D3.js.


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.

d <- diamonds[sample(nrow(diamonds), 1000), ]

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
Statistical Charts
Scientific Charts
Layout Options
Image Export & Retrieving Plots
Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to our Premium or Enterprise plans.