import plotly.plotly as py
from plotly.graph_objs import *
import plotly.tools as tls
import pandas as pd
import plotly
plotly.__version__
py.sign_in('Python-Demo-Account','gwt101uhh0')
The graph below was built by Andy Kriebel. Here, we're embedding the Workbook inside our IPython Notebook.
df = pd.read_csv("http://public.tableausoftware.com/views/WomenManagers/WomanPower.csv")
df.head() # take a look at data
Now we can plot the data inside Plotly and make a histogram.
histogram_plot = [{'x': df['% of women managers'],
'type': 'histogram',
'name': '% of women managers',
}]
data_histogram = Data(histogram_plot)
fig_histogram = Figure(data=data_histogram)
py.iplot(fig_histogram, filename='% of women managers')
tls.embed('MattSundquist',8651) # style in GUI
fig = py.get_figure('MattSundquist',8651) # or, I can get the data
fig_data = fig.get_data()
str(fig_data)
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.
from IPython.core.display import HTML
import urllib2
HTML(urllib2.urlopen('https://raw.githubusercontent.com/plotly/python-user-guide/css-updates/custom.css').read())