By Vasudev Ram
I had blogged a couple of times earlier about plot.ly, here:
plot.ly, fast plotting in the browser
and here:
Plot me some randomness
Saw today via Twitter that plot.ly now has an API: plot.ly API
The current Hacker News thread about plot.ly has co-founder cparmer participating. He says in a comment in that thread, that after they first released plot.ly, the top request was for an API. They have now released it, with support for Python, MATLAB, R and Arduino.
Took a look at the plot.ly API page and it looks interesting.
Excerpt from the page:
[ Send data to your Plotly account from your desktop environment through our APIs and view your plot at a unique URL. Available for Python, R, MATLAB, and Arduino. ]
You can install the plot.ly module for Python via pip (or other methods).
After that you can generate a plot.ly plot from code on your desktop via the API and then get back a link/URL to the plot on the plot.ly site.
An interesting feature is that you can sign up programmatically via the plot.ly API.
Here is an example program using the plot.ly API, only slightly modified from their docs:
# One-time stuff to import plotly, and sign up via the API. import plotly # Para 1 username='v.ram' email='obscured@obscured.com' response = plotly.signup(username, email) api_key = response['api_key'] tmp_pw = response['tmp_pw'] print "api_key:", api_key print "tmp_pw:", tmp_pw # Stuff that can repeat/vary, to use plot.ly # Para 2 py = plotly.plotly(username='v.ram', key='obscured') x0 = ['giraffes', 'orangutans', 'monkeys'] y0 = [20, 14, 23] data = {'x': x0, 'y': y0, 'type': 'bar'} response = py.plot([data]) url = response['url'] filename = response['filename'] print "url:", url print "filename:", filename
And here is the output from running that program:
High five! You successfuly sent some data to your account on plotly. View your plot in your browser at https://plot.ly/~v.ram/0 or inside your plot.ly account where it is named 'plot from API' url: https://plot.ly/~v.ram/0 filename: plot from APII then pasted the link above in my browser and it showed the plot.
You will have to change the values in the above code for username and email, to values of your own, and then run the program.
Of course, the plot.ly API is new, but it looks useful and worth checking out.
Here is a screenshot of the plot generated by the above Python plot.ly code:
- Vasudev Ram - Dancing Bison Enterprises
Contact me
No comments:
Post a Comment