Hi @Yabadabadou,
Welcome to Plotly forum!
The plotly.figure_factory.create_table()
is obsolete. To get the same plot use plotly.subplots.make_subplots
https://plotly.com/python/subplots/, and go.Table
https://plotly.com/python/table/.
The following code defines the two subplots and moreover add title for table:
import plotly.graph_objects as go
from plotly.subplots import make_subplots
fig = make_subplots(
rows=2, cols=1,
subplot_titles=('Bar plot title', 'Table title'),
vertical_spacing=0.12,
specs=[[{"type": "xy"}],
[{"type": "table"}]]
)
# 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, 3.18]
GAPG = [2.17, 2.57, 2.0, 2.91, 2.57, 2.77]
fig.add_trace(go.Bar(x=teams, y=GFPG,
marker=dict(color='#0099ff'),
name='Goals For<br>Per Game'), 1,1)
fig.add_trace(go.Bar( x=teams, y=GAPG,
marker=dict(color='#404040'),
name='Goals Against<br>Per Game'),1,1)
fig.add_trace(
go.Table(
header=dict(
height=50,
values=['<b>Team</b>', '<b>Wins</b>', '<b>Losses</b>', '<b>Ties</b>'],
font_size=14,
font_color='white',
align="left",
fill_color='#404040'
),
cells=dict(
values=[['Montréal<br>Canadiens',
'Dallas Stars',
'NY Rangers',
'Boston<br>Bruins',
'Chicago<br>Blackhawks',
'Ottawa<br>Senators'], #data for the first table column
[18, 18, 16, 13, 13, 12],# second column
[4, 5, 5, 8, 8, 5], # third column
[0, 0, 0, 0, 0, 0]],# fourth column
align = "left",
height=40)), row=2, col=1)
fig.update_layout(title_text='2016 Hokey Stats', height=900)