Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtitle does not render following example from docs #4715

Closed
hannahker opened this issue Aug 13, 2024 · 3 comments
Closed

Subtitle does not render following example from docs #4715

hannahker opened this issue Aug 13, 2024 · 3 comments
Assignees
Labels
bug something broken P2 considered for next cycle

Comments

@hannahker
Copy link

hannahker commented Aug 13, 2024

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:

Screenshot 2024-08-13 at 1 50 04 PM

I have validated that I have installed plotly==5.23.0.

@gvwilson gvwilson added bug something broken P2 considered for next cycle labels Aug 16, 2024
@rusiano
Copy link

rusiano commented Oct 20, 2024

+1

@ndrezn
Copy link
Member

ndrezn commented Oct 24, 2024

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: microsoft/vscode-notebook-renderers#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.

Image

@ndrezn
Copy link
Member

ndrezn commented Oct 24, 2024

I am going to close in favour of #4827 but feel free to re-open if my diagnosis above is incorrect.

@ndrezn ndrezn closed this as completed Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P2 considered for next cycle
Projects
None yet
Development

No branches or pull requests

5 participants