suppressMessages(library(devtools))
suppressMessages(install_github("ropensci/plotly"))
suppressMessages(library(ggplot2))
suppressMessages(library(plyr))
suppressMessages(library(plotly))
py <- plotly(username="r_user_guide", key="mw5isa4yqp") # open plotly connection
# grab data from Tableau
df <- read.csv("http://public.tableausoftware.com/views/WomenManagers/WomanPower.csv")
# verify, show first 5 rows
df[1:5,]
ggplot(df, aes(x=Latitude..generated.)) + geom_histogram()
suppressMessages(py$ggplotly(session="notebook")) # send to plotly, embed in Notebook
plotly_iframe <- function(url) {
# set width and height from options or default square
w <- "600"
h <- "600"
html <- paste("<iframe height=\"", h, "\" id=\"igraph\" scrolling=\"no\", seamless=\"seamless\"\n\t\t\t\tsrc=\"",
url, "\" width=\"", w, "\" frameBorder=\"0\"></iframe>", sep = "")
return(html)
}
display_html( plotly_iframe("https://plot.ly/~MattSundquist/8740")) # edit in GUI, embed
# CSS styling within IPython notebook
display_html(getURL("https://raw.githubusercontent.com/plotly/python-user-guide/master/custom.css"))