Introduction to Plotly

Andrew Tran
September 16, 2015

Go to plotly.com or plot.ly

Create an account!

Wait, wait, wait

What is Plotly?

Plotly is an online analytics and data visualization tool, headquartered in Montreal, Quebec. Plotly provides online graphing, analytics, and stats tools for individuals and collaboration, as well as scientific graphing libraries for Python, R, MATLAB, Perl, Julia, Arduino, and REST.

Plotly was built using Python and the Django framework, with a front end using JavaScript and the visualization library D3.js, HTML and CSS. Files are hosted on Amazon S3.

Other chartbuilders out there

Why plotly?

  • Plot.ly has a graphical user interface for importing and analyzing data into a grid and using stats tools. Graphs can be embedded or downloaded.
  • API libraries for Python, R, MATLAB, Node.js, Julia, and Arduino and a REST API. Plotly can also be used to style interactive graphs with IPython.
  • Figure Converters which convert matplotlib, ggplot2, and IGOR Pro graphs into interactive, online graphs.
  • Plotly Apps for Google Chrome.
  • Plotly.js is a JavaScript library for creating graphs and dashboards.
  • Plotly Enterprise an on-premises installation of Plotly.

OK, you've signed up

Welcome to plot.ly/feed

Click on any of the examples

Click the DATA tab.

Now you can see how the data was organized

Or click Fork & Edit

Click SAVE if you want to save a copy of it to your list of projects.

Let's start from scratch

Click on +NEW PROJECT button at the top right or click on the +NEW GRID button at the top left (depending on what page you're on)

Let's start from scratch

Click on +NEW PROJECT button at the top right or click on the +NEW GRID button at the top left (depending on what page you're on)

Preparing the data

Lets bring in homicide data.

Problem: Even though the data from the UCR came in this horizontal format, the structure needed for the chart is vertical.

Solution: Copy and Paste special > Paste transpose.

Bringing in the data

Copy and paste the new columns into plotly.

Choose the Y headers

Make sure the new columns are recognized by selecting choose as y.

Rename the column titles

Click the little gray triangle next to each of the Col names and click Rename. Change the headers to the titles.

Remove the old row with the titles

Select the entire row and right click. Then select Remove selected row.

Close!

Your data is still in the tab on the top left in one of the Grid tabs.

Click in the box in the title, x axis, and y axis to change the text.

Changing the style

Select any of the premade themes on the left.

Changing the style

Or play around with the icons near the top.

Traces will let you change the color of each individual line.

More style

The Legend icon will let you play with options like background color and position.

More style

I got rid of the grid lines by clicking on AXES and then Lines and checking Grid lines to off.

Adding annotations

This is one of the most useful parts about plotly.

Click NOTES then New text and text with an arrow will appear on the chart. From here, you can customize it by dragging it where you want to go and even hiding the arrowhead if you want.

Done?

Click SAVE and then Share.

Get the shareable link or the embed code. Whatever you need.

Done?

Or hover and find the camera icon and click it to save it as an image file.