Plotly ggplot2 Library

library(plotly)

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

ggplotly()
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.

set.seed(100)
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


Aesthetics

aes
aes

Geoms

geom_polygon
geom_polygon
geom_density
geom_density
geom_histogram
geom_histogram
geom_line
geom_line
geom_abline
geom_abline
geom_ribbon
geom_ribbon
stat_smooth
stat_smooth
geom_smooth
geom_smooth
geom_bar
geom_bar
geom_boxplot
geom_boxplot
geom_point
geom_point
ggdendro lattice dendrograms
ggdendro lattice dendrograms
geom_errorbar
geom_errorbar

Faceting

facet_grid
facet_grid
facet_wrap
facet_wrap

Other

scale_y_continuous
scale_y_continuous
scale_x_date
scale_x_date
interactive tooltip
interactive tooltip

theme

axis.title
axis.title
axis.ticks
axis.ticks
axis.text
axis.text

Image Export & Retrieving Plots