Plotly Beta: Collaborative Plotting with R

(Guest post by Matt Sundquist on a lovely new service which is pro-actively supporting an API for R)

The Plotly R graphing library  allows you to create and share interactive, publication-quality plots in your browser. Plotly is also built for working together, and makes it easy to post graphs and data publicly with a URL or privately to collaborators.

In this post, we’ll demo Plotly, make three graphs, and explain sharing. As we’re quite new and still in our beta, your help, feedback, and suggestions go a long way and are appreciated. We’re especially grateful for Tal’s help and the chance to post.

Installing Plotly

Sign-up and Install (more in documentation)

From within the R console:


Next, install plotly (a big thanks to Hadley, who suggested the GitHub route):

# ...
# * DONE (plotly)

Then sign-up like this or at

>response = signup (username = 'username', email= 'youremail')
Thanks for signing up to plotly!
Your username is: MattSundquist
Your temporary password is: pw. You use this to log into your plotly account at Your API key is: “API_Key”. You use this to access your plotly account through the API.
To get started, initialize a plotly object with your username and api_key, e.g.
>>> p < - plotly(username="MattSundquist", key="API_Key")
Then, make a graph!
>>> res < - p$plotly(c(1,2,3), c(4,2,1))

And we’re up and running! You can change and access your password and key in your homepage.

1. Overlaid Histograms:

Here is our first script.

p < - plotly(username="USERNAME", key="API_Key")
x0 = rnorm(500)
x1 = rnorm(500)+1
data0 = list(x=x0,
data1 = list(x=x1,
layout = list(barmode='overlay')
response = p$plotly(data0, data1, kwargs=list(layout=layout))

The script makes a graph. Use the RStudio viewer or add “browseURL(response$url)” to your script to avoid copy and paste routines of your URL and open the graph directly.


Continue reading Plotly Beta: Collaborative Plotting with R