Reputation: 3
I am having a issue with size of the second graph added to the tab widget, which is not of the size of all the container: here is by code
''' output_co2 = widgets.Output()
output_co = widgets. Output()
tab = widgets.Tab(children=[output_co2, output_co],
layout=widgets.Layout(width='100%', height='100%'))
tab.set_title(0, 'CO2')
tab.set_title(1, 'CO')
display(tab)
with output_co2:
fig = go.Figure()
fig.add_trace(go.Scatter(x=vehicleData['distance_m']/1000,
y=vehicleData['co_gs'],
name='CO [g/s]',
mode="lines",
line=dict(
width=2),
fig.show()
with output_co:
fig = go.Figure()
fig.add_trace(go.Scatter(x=vehicleData['distance_m']/1000,
y=vehicleData['co_gs'],
name='CO [g/s]',
mode="lines",
line=dict(
width=2),
fig.show() '''
enter image description here enter image description here
Upvotes: 0
Views: 831
Reputation: 3199
With plotly you need to use the go.FigureWidget()
in place of go.Figure()
, see here. So something like this:
output_co2 = widgets.Output()
output_co = widgets.Output()
tab = widgets.Tab(children=[output_co2, output_co])
tab.set_title(0, 'CO2')
tab.set_title(1, 'CO')
display(tab)
with output_co2:
fig = go.FigureWidget() # HERE
fig.add_trace(go.Scatter(x=vehicleData['distance_m']/1000,
y=vehicleData['co_gs'],
name='CO [g/s]',
mode="lines",
line_width=2))
fig.show()
with output_co:
fig = go.FigureWidget() # AND HERE
fig.add_trace(go.Scatter(x=vehicleData['distance_m']/1000,
y=vehicleData['co_gs'],
name='CO [g/s]',
mode="lines",
line_width=2))
fig.show()
Alternative:
With plotly you can use go.FigureWidget()
directly instead of widgets.Output()
fig1 = go.FigureWidget()
fig2 = go.FigureWidget()
tab = widgets.Tab(children=[fig1, fig2])
tab.set_title(0, 'CO2')
tab.set_title(1, 'CO')
fig1.add_trace(go.Scatter(x=vehicleData['distance_m']/1000,
y=vehicleData['co_gs'],
mode="lines",
line_width=2))
fig2.add_trace(go.Scatter(x=vehicleData['distance_m']/1000,
y=vehicleData['co_gs'],
mode="lines",
line_width=2))
display(tab)
Upvotes: 0