Plotting With Python, Tableau, & Plotly

In [1]:
import plotly.plotly as py
from plotly.graph_objs import *
import as tls
import pandas as pd
In [2]:
import plotly
In [3]:

The graph below was built by Andy Kriebel. Here, we're embedding the Workbook inside our IPython Notebook.

In [4]:
df = pd.read_csv("")
In [5]:
df.head()  # take a look at data
Country Latitude (generated) Longitude (generated) % of women managers
0 Albania 40.6540 20.076 22.5%
1 Algeria 28.6045 2.640 4.9%
2 Argentina -33.1660 -64.310 31.0%
3 Aruba 12.5560 -70.024 41.0%
4 Australia -24.5780 133.582 36.2%

Now we can plot the data inside Plotly and make a histogram.

In [6]:
histogram_plot = [{'x': df['% of women managers'], 
                 'type': 'histogram',
                 'name': '% of women managers',
In [7]:
data_histogram = Data(histogram_plot)
In [8]:
fig_histogram = Figure(data=data_histogram)
In [9]:
py.iplot(fig_histogram, filename='% of women managers')
In [10]:
tls.embed('MattSundquist',8651)  # style in GUI
In [11]:
fig = py.get_figure('MattSundquist',8651)  # or, I can get the data
In [12]:
fig_data = fig.get_data()
In [13]:
"[[u'22.5%', u'4.9%', u'31.0%', u'41.0%', u'36.2%', u'30.0%', u'34.2%', u'44.4%', u'5.4%', u'43.4%', u'46.2%', u'32.4%', u'41.3%', u'43.5%', u'27.6%', u'35.1%', u'38.6%', u'37.3%', u'36.4%', u'18.0%', u'36.2%', u'42.4%', u'23.6%', u'16.8%', u'53.1%', u'27.9%', u'27.6%', u'38.1%', u'15.8%', u'26.2%', u'28.4%', u'38.6%', u'39.7%', u'9.7%', u'37.1%', u'32.8%', u'22.1%', u'29.7%', u'39.4%', u'34.0%', u'31.1%', u'39.0%', u'25.1%', u'44.8%', u'23.9%', u'33.2%', u'38.6%', u'39.9%', u'21.2%', u'14.6%', u'32.6%', u'31.8%', u'25.8%', u'59.3%', u'11.1%', u'5.1%', u'37.2%', u'36.4%', u'14.8%', u'13.9%', u'32.3%', u'45.7%', u'8.4%', u'21.4%', u'38.8%', u'18.0%', u'31.4%', u'23.1%', u'36.6%', u'21.5%', u'13.4%', u'27.0%', u'23.4%', u'32.0%', u'44.1%', u'41.9%', u'27.3%', u'12.8%', u'36.0%', u'29.0%', u'40.0%', u'41.0%', u'32.2%', u'9.3%', u'3.0%', u'14.4%', u'47.4%', u'32.3%', u'29.3%', u'47.6%', u'37.8%', u'34.6%', u'6.8%', u'31.4%', u'39.1%', u'34.0%', u'52.3%', u'7.1%', u'29.1%', u'40.8%', u'31.4%', u'33.1%', u'39.0%', u'31.3%', u'11.0%', u'30.0%', u'28.4%', u'35.5%', u'33.2%', u'10.2%', u'16.5%', u'28.2%', u'43.1%', u'14.8%', u'12.2%', u'20.2%', u'39.9%', u'10.0%', u'34.2%', u'42.7%', u'43.9%', u'28.5%', u'33.4%', u'23.0%', u'2.1%', u'20.6%']]"

If someone runs this Notebook, they will fetch the most recent, up to date data from Tableau. If you are using updating graphs in Tableau, that gives you a quick way to grab and share data and graphs between everyone. Similarly, if you embed a live-streaming or 3D in a Tableau dashboard, as we've done below, you can also see live updating data.

In [14]:
from IPython.core.display import HTML
import urllib2