Example on Plotly Site Doesn't Work

I tried this example, but instead of getting the two legends, I only get one. I’m running plotly version 5.18.0, which should be fine. How am I getting a different plot with copy/pasted code from the one shown in the example?

Hi @danielkwalsh ,

Welcome to the community!

can you capture the figure ?
it will be help us to narrow your issues.

Thanks.

Yes, absolutely. Here’s the image I get:

Hi @danielkwalsh ,

I have tried to copy-paste the example and use version 5.18.0 as you do but it seems work fine.

I am not sure this is a bug.

But, maybe you can try to explicitly add :

  • legend="legend" on Germany, France and UK traces
  • legend="legend2" on Europe and Americas traces.
...

fig = go.Figure(
    data=[
        go.Scatter(x=df_germany.year, y=df_germany.gdpPercap, name="Germany", legend="legend"),
        go.Scatter(x=df_france.year, y=df_france.gdpPercap, name="France"), legend="legend",
        go.Scatter(x=df_uk.year, y=df_uk.gdpPercap, name="UK", legend="legend"),
        go.Scatter(
            x=df_averages_europe.index,
            y=df_averages_europe.gdpPercap,
            name="Europe",
            legend="legend2",
        ),
        go.Scatter(
            x=df_averages_americas.index,
            y=df_averages_americas.gdpPercap,
            name="Americas",
            legend="legend2",
        ),
    ],
...

Hope this help.

Hi @danielkwalsh welcome to the community.

Just to narrow it down, are you using Jupiter?

I tried use Jupyter and came up showing two type of legend, but it show just one legend name.
it is like a legend but has different color.

even explicitly using legend=β€˜legend’ and legend=β€˜legend2’, it remain the same.

Nice hint @AIMPED . :slightly_smiling_face:

1 Like

There are still compatibility problems with Jupiter >=4, I think.

I am using an ipynb in VS Code.