I’m currently creating some offline Plotly (v4) plots in JupyterLab and they show up in the notebook but show as blank when exported to HTML. I’ve traced the issue back to the use of a custom template. Below are two minimum working examples: the first demonstrates the problem when using a custom template, while the second functions once the custom template is removed. My thought is that nbconvert isn’t properly embedding the relevant non-default template information, but I’ve haven’t been able to trace down the specifics. Thoughts?
Exported HTML shows blank space where the figure should be
import plotly.graph_objects as go
# Define the default tick formatting
tickformatting = {'ticks': "outside",
'tickfont': {'size': 18},
'showticksuffix': 'all',
'showtickprefix': 'last',
'showline': True
}
# Create a default template for the plotly plots
template = go.layout.Template(
layout=go.Layout(title_font={'color': '#7f7f7f', 'family': 'Sans-serif', 'size': 24},
font={'color': '#7f7f7f', 'family': 'Sans-serif', 'size': 18},
xaxis=dict(**tickformatting),
yaxis=dict(**tickformatting),
margin={"l": 150, "r": 150})
)
fig = go.Figure()
fig.update_layout(title="Figure Title",
template=template)
fig.show()
Exported HTML shows figure
import plotly.graph_objects as go
# Define the default tick formatting
tickformatting = {'ticks': "outside",
'tickfont': {'size': 18},
'showticksuffix': 'all',
'showtickprefix': 'last',
'showline': True
}
# Create a default template for the plotly plots
template = go.layout.Template(
layout=go.Layout(title_font={'color': '#7f7f7f', 'family': 'Sans-serif', 'size': 24},
font={'color': '#7f7f7f', 'family': 'Sans-serif', 'size': 18},
xaxis=dict(**tickformatting),
yaxis=dict(**tickformatting),
margin={"l": 150, "r": 150})
)
fig = go.Figure()
fig.update_layout(title="Figure Title")
fig.show()