Subtitle does not render following example from docs
Following this example from the docs, I'm not able to get a subtitle to render:
import plotly.graph_objects as go
from plotly import data
df = data.gapminder().query("continent == 'Europe' and (year == 1952 or year == 2002)")
df_pivot = df.pivot(index="country", columns="year", values="lifeExp")
fig = go.Figure(
[
go.Bar(
x=df_pivot.index, y=df_pivot[1952], name="1952", marker_color="IndianRed"
),
go.Bar(
x=df_pivot.index, y=df_pivot[2002], name="2002", marker_color="LightSalmon"
),
],
layout=dict(
title=dict(
text="Life Expectancy",
subtitle=dict(
text="Life expectancy by European country in 1952 and in 2002",
font=dict(color="gray", size=13),
),
)
),
)
fig.show()
This code outputs:
I have validated that I have installed plotly==5.23.0.
+1
Are both/either of you using VSCode notebooks and experiencing this issue? My guess is yes...
If you are using VSCode notebooks to generate your chart, you'll need to manually specify the notebook renderer because the builtin Plotly.js for VSCode notebooks is too old. See: https://github.com/microsoft/vscode-notebook-renderers/pull/199
The workaround is to add:
import plotly.io as pio
pio.renderers.default = "notebook_connected"
to your notebook.
Rather than validating the version of the Python package, can you check the version of Plotly.js in use by hovering over the Plotly icon in the modebar? Subtitles were added in v2.34.0, so this should be >=2.34.0.
I am going to close in favour of #4827 but feel free to re-open if my diagnosis above is incorrect.