Getting Data

Keeping track of your data source is important. That’s why Plotly automatically includes a link to the URL that hosts your data.

You can also sync Plotly graphs with externally sourced data. These graphs can be shared by a URL or embedded in a webpage, and whenever a user views the graph, Plotly fetches the latest data from your web service. Use the external source plotter when you don’t want to send your user to Plotly’s Web App. We have examples documented for SQLite, Flask, Quandl, Google Drive, GitHub Gists, and Dropbox.

Data.gov is the home of the U.S. Government's open data and hosts over 124,651 data sets. They've recently built an "Open With" option that let's you send the data directly to Plotly to create interactive graphs for free. This feature is supported on smaller CSV and XLS files. Look for the "Open With" menu when searching through their data sets.

When you go to Data.gov, you'll see a box to search the data sets and icons to browse by topic.

We selected Consumer, which opens a description of the collection, highlights, and recent updates. Clicking on Data brings us to the data sets.

The toolbar on the left lets us filter the data by type, tags, format, and more. If you want to quickly find data sets that you can export to Plotly, filtering the format to XLS or CSV is helpful.

Once you select a data set, look for the "Open With" option (this will only appear on supported data sets). Click on plotly, and the data set will open inside Plotly's Web App.

WebPlotDigitizer lets you automatically grab data from an image and export the data directly to Plotly. With Plotly you can recreate an interactive version of the graph, easily stylize your work, and even analyze the data.

Let’s say, for example, you’re reading this Mother Jones article on the rising strength of hurricanes. The source of this data is an academic paper we don’t have access to, but WebPlotDigitizer can grab the data and send it Plotly.

The first step is to save a copy of the image (or take a screen shot). Then open WebPlotDigitizer’s App. Click on File, and then Load Image. Upload your saved image.

We select the plot type (in this case “2D (X-Y) Plot”) and click on Align Axes. WebPlotDigitizer gives simple instructions to select four points to align the axes.

This particular graph has an $x$-axis with value labels but no tick marks. To be as precise as possible, we can mouse over a known value, such as the data peak at 1983. Any time you mouse over your WPD graph, the panel in the upper right corner zooms in and displays coordinates as $[x,y]$. Once we find the appropriate $x$-coordinate (in this case 73.78), we can move our mouse to the $x$-axis to select the first point.

We use the same method for the other three points. Click Complete! once you’ve selected four points.

We now enter the point values we selected for the points selected on the $x$ and $y$ axes. Because this graph has years on the $x$-axis, we use the format “yyyy/mm/dd”. Click Okay.

We’ll use the default manual mode, and add a point by clicking on each peak and valley on the line that defines the graph. Once this is complete, we click on View Data to open the extracted data set.

Click on the Graph in Plotly button to recreate the graph. Once the graph loads, you can click on VIEW DATA to see the underlying data.

Quandl is a search engine for numerical data. They host data sets from hundreds of publishers, all organized and easy to search. Quandl automatically sends data to a new Plotly spreadsheet, neatly formatted, organized and ready for graphing.

Import.io is a great service to help you scrape data automatically from webpages. To utilize the Plotly export, you’ll need to head over to import.io and set up a free account.

Ikea (in Canada) has 77 table lamps for sale on their webpage. Let’s say you are interested in the average price of their offerings, or perhaps would like to make a histogram of the prices. Instead of manually extracting the data, we can use import.io.

Open import.io, and sign in. Enter the URL of the page with the data you want to extract. Click on Try it Out.

You’ll see the data appear in spreadsheet form. Look for the pink Get API button in the lower right. Click it.

Click on the Copy this to My Data button in the box that appears, and you’ll see the data in a form where we can select columns to extract. Click the Plot.ly button above the data.

We can check the columns of data what we wish to extract to Plotly. Here we choose “producttitle_value” and “price_value_prices”. Finally, click on the blue Export to Plot.ly button.

The data will open in a Plotly grid, where you can analyze and graph the data. You might like to check out our tutorials on basic statistics and histograms to get some ideas.

Vernier develops and produces easy-to-use data-aquisition products (think sensors, data loggers, and experiments) for science classrooms and labs around the world. Vernier's Data Share Apps (built for iPad, Android, Chromebooks, and mixed-device classrooms), allow you to use their excellent hardware across platforms, from most devices. You can export data directly to Plotly, which gives you a seamless workflow on your Chromebook, iPad, or tablet. An export to Plotly with Logger Pro is coming soon.

Click on the Download icon in the top-right corner of the Data Share web app. Select Export to Plotly to open the collected data in Plotly's web app.