How to share your figure in the cloud

Original blog illustration by Cali Rossi

Original blog illustration by Cali Rossi

Today is a special post for a new online tool that hold some very interesting future. It’s about a new online tool from plot.ly, a startup company in Montreal. I like their work a lot and decided it was worth giving them some little pushes as modestly as I can.

The idea is simple : Sharing your figures and plots in the cloud instead of sending good old screenshots.

I am starting to be seriously deep into academia now and with most folks around me, we routinely spend a lot of time arguing how we would like the publication system to be. But there is one thing we usually all agree : it needs to change. This is the 21st century! How can we still be publishing papers in the digital age? Even the word is antediluvian: I don’t write on papers, I don’t read on paper, I don’t work on papers. It’s more than time to explore new publications technologies.

One reason why the web has not taken over this segment is that, actually, the way we use to display data (ie. screenshot or fixed capture of our figures) is not superior when embedded in html files. The truth is : pdf files are still better to showcase your work. But this is just about to change.

To me, this is what plot.ly and Matlab provides : a way to really benefit from modern computer capabilities and bring back science publication into the 21st century.

Alright, what am I talking about and why am I so enthusiast?

Take a look at this figure :

There are two things to note on this figure. First the data is quite interesting. This is the amount of request done on google over time for “Weight loss”. I am sure you notice how the graph “spikes” every single year at the end of december and early january. Funny, isn’t?

But now note how beautiful this display tool is, you can zoom in and out, focus on some part, pan around. But best of all, you can ACTUALLY access the underlying data and all of this right there in your browser: Just click on the “data and graph” link at the bottom right. To us, researcher, this is a dream come true. At last, we have a way to both display our results and share the raw values so that someone might actually use it do some research of its own. I remember, back in 2003, how, as a student, I was supposed to fit a new model to published data. I quite distinctively remember the painful process of extracting the data from the graph. Here it’s just one click away…

Now, here is my call : Dear journal editor all over the planet, consider how powerful such tool could be for your journal publications. Consider how this would improve the ethical standards of research on all fronts. I have a dream that…

Sorry, I am getting too excited.

How does it work?

It’s very easy:

Now you can go to Matlab and send graphs to the cloud. I used the following data file to generate the “Weight loss” plot : 

Using this file, I generate the online plot using :

% This is the day google trend data starts</pre>
FirstWeekDay='01 04, 2004';
FirstDayNumeral=datenum(FirstWeekDay,'mm dd, yyyy');

% We read the actual data
SearchDataInterest = csvread('report.csv',5,1);

% We create the array of days number
NumeralDayArray=7*(0:(numel(SearchData)-1));

% We shift from the first numeral
NumeralDayArray=NumeralDayArray+FirstDayNumeral;

% Replace XXXX with you API key

signin('XXXX','XXXX');

xStringData=datestr(NumeralDayArray,'yyyy-mm-dd HH:MM:SS');

layout = struct('title', 'Google search on Weight loss','xaxis', struct('title','Date'),'yaxis',struct('title','Search interest'));

response=plotly(cellstr(xStringData),SearchDataInterest,struct('layout',layout));
url = response.url

url will hold the html address to the generated plot. In this particular example, the url is :

https://plot.ly/~Matlabtips/104

I invite you to get a look at that link. Plot.ly is more than just an online figure display engine. They designed their system as a social network. You have access to an online collaborative tool (a little like google docs) where you can, as a team, work on the figure and share it around. There are also building a number of tools around the data, including some analysis tools.

For now, plotly syntax is a little unusual. All is documented here with many examples. Basically you have to use embedded structures to pass various parameters to their online display engine. As a Matlab user, It’s a little awkward at the beginning but you get used to it pretty quickly.

Once you have the url, you can either send it to your colleague or actually embed it on a blog like this one. I used the following code :

<iframe src=”https://plot.ly/~Matlabtips/104″ height=”400″ width=”500″ seamless=”seamless” scrolling=”no”></iframe>

Now that you know everything, let’s have some fun. Using the same data, I generated an average of the year distribution of “Weight loss” request.

Have a look, it’s quite interesting.

The red curve is the yearly average.

Now, with plotly you can actually zoom in and explore that graph. Indeed it spikes at new year. Everybody wants to lose weight there after the feast. I suppose you also saw that people actually start to be worried just before christmas (“Oh my god, what I am cooking there…”). There is also a little spike in the summer and the interest in Weight loss drops steadily right at the end of the beach season.

Related Posts

This entry was posted in Advanced, Beginners, Intermediate, Various. Bookmark the permalink.

3 Responses to How to share your figure in the cloud

  1. Tom Wainwright says:

    Now this, this is awesome.

  2. keith says:

    I agree.

  3. Joseph says:

    Wow… I just checked out plotly and their js library is terrific. I’ll be able to do a lot of new graphs that I can’t do with matlab now. check it: http://goo.gl/5K3z70

Leave a Reply