About
R module of Plotly
Installation
install.packages("viridis") # dependency
install.packages("devtools")
devtools::install_github("ropensci/plotly")
Installing 11 packages:
- dichromat,
- gtable,
- labeling,
- munsell,
- plyr,
- proto,
- RColorBrewer,
- reshape2,
- scales
Login
Login parameter that you get from the website > Settings > Settings API
Sys.setenv("plotly_api_key" = "cr0p34587")
Sys.setenv("plotly_username" = "gerardnico")
Graph
plot_ly
library(plotly)
set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]
plot_ly(d, x = carat, y = price, text = paste("Clarity: ", clarity),
mode = "markers", color = carat, size = carat)
ggplot
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))