Skip to content
forked from plotly/plotly.R

Create interactive web graphics from R via plotly's JavaScript graphing library

License

Notifications You must be signed in to change notification settings

Disruptives/plotly

 
 

Repository files navigation

Build Status

plotly

An R package for creating interactive web-based graphs via plotly's JavaScript graphing library.

Installation

Install from CRAN:

install.packages("plotly")

Or install the latest development version (on GitHub) via devtools:

devtools::install_github("ropensci/plotly")

Introduction

If you use ggplot2, simply call ggplotly() to convert your ggplot to an interactive, web-based version!

library(plotly)
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))) +
  geom_smooth(aes(colour = cut, fill = cut)) + facet_wrap(~ cut)
(gg <- ggplotly(p))

https://plot.ly/~agvd/1153

Click here to interact with the resulting graph (notice the custom hover text!)

plotly also supports certain chart types that ggplot2 doesn't support (such as 3D surface, point, and line plots). You can easily create these (or any other plotly) charts using the high-level interface.

plot_ly(z = volcano, type = "surface")

https://plot.ly/~brnvg/1134

The ggplotly() function converts a ggplot object to a plotly object, so if you like, you may 'post-process' your ggplot graphs to add custom plotly features, for example:

layout(gg, hovermode = "closest")

Learn more

Contributing

Stay in touch


About

Create interactive web graphics from R via plotly's JavaScript graphing library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • R 99.8%
  • JavaScript 0.2%