R - Plotly

> Procedural Languages > R

1 - About

R module of Plotly

2 - 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
Advertising

3 - Login

Login parameter that you get from the website > Settings > Settings API

Sys.setenv("plotly_api_key" = "cr0p34587")
Sys.setenv("plotly_username" = "gerardnico")

4 - Graph

4.1 - 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)

4.2 - ggplot

R - 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))

5 - Documentation / Reference

lang/r/plotly.txt · Last modified: 2017/06/23 14:13 by gerardnico