Thanks, That works.
how to make the graph on top of the table, instead of on the right?
I tried myself, as below, but the table is missing header, and the graph label is wrong too.
Can you update the tutorial with another example to show how to make the graph on top of the table please?
Thanks
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.tools import FigureFactory as FF
# Add table data
table_data = [['Team', 'Wins', 'Losses', 'Ties'],
['Montréal<br>Canadiens', 18, 4, 0],
['Dallas Stars', 18, 5, 0],
['NY Rangers', 16, 5, 0],
['Boston<br>Bruins', 13, 8, 0],
['Chicago<br>Blackhawks', 13, 8, 0],
['LA Kings', 13, 8, 0],
['Ottawa<br>Senators', 12, 5, 0]]
# Initialize a figure with FF.create_table(table_data)
figure = FF.create_table(table_data, height_constant=60)
# Add graph data
teams = ['Montréal Canadiens', 'Dallas Stars', 'NY Rangers',
'Boston Bruins', 'Chicago Blackhawks', 'Ottawa Senators']
GFPG = [3.54, 3.48, 3.0, 3.27, 2.83, 2.45, 3.18]
GAPG = [2.17, 2.57, 2.0, 2.91, 2.57, 2.14, 2.77]
# Make traces for graph
trace1 = go.Scatter(x=teams, y=GFPG,
marker=dict(color='#0099ff'),
name='Goals For<br>Per Game',
xaxis='x2', yaxis='y2')
trace2 = go.Scatter(x=teams, y=GAPG,
marker=dict(color='#404040'),
name='Goals Against<br>Per Game',
xaxis='x2', yaxis='y2')
# Add trace data to figure
figure['data'].extend(go.Data([trace1, trace2]))
# Edit layout for subplots
figure.layout.yaxis.update({'domain': [0, .45]})
figure.layout.yaxis2.update({'domain': [0.6, 1.]})
# The graph's yaxis MUST BE anchored to the graph's xaxis
figure.layout.yaxis2.update({'anchor': 'x2'})
figure.layout.yaxis2.update({'title': 'Goals'})
# Update the margins to add a title and see graph x-labels.
figure.layout.margin.update({'t':50, 'b':100})
figure.layout.update({'title': '2016 Hockey Stats'})
# Plot!
plot_url = py.plot(figure, filename='subplot_table')