I’m using the new feature of Plotly 5.15, enabling to position groups of legend, as described at thebottom of this page:
My figure has 1 shared xaxis and 5 yaxis. The particularity of this chart is that I have 4 series (one per currency) of 7 traces (one per measure). SInce the Y axis are not in the same unit, I have different y axis.
When plotting, I hide the legend for all traces but one. FInal result is like this in a standalone figure:
In short: it works.
However, this very same code, rendered into my dash app, gives:
Question: how is it possible for the very same code to position the legend at the bottom of the chart rather than at the top ?
Can it be a bug ?
It is a bug; I will document and provide MRE later but here is the source of the issue:
If the layout does have “legend”, “legend1”, “legend2”, etc, while the traces only shows legend for “legend2”, then this “legend2” is not positioned correctly when the figure is rendered into the dash app.
to fix it, I set the legend of my trace to “legend” rather than “legend2”, commented the “legend”, “legend3”, “Legend4” in the layout to get rid of them, and renamed “legend2” as “legend”.
Now, the figures renderd with fig.show() and the one in my dash app are identical with the legend on top of the figure.
In short: I think there are issues if there are several legend defined in the layout, while only one is used by the trace.
There is also issues if the single legend defined in the layout is “legend2” rather than “legend”, while the legend of the trace is set to “legend2” rather than “legend”. By default it behaves as if yref was set on “container” rather than “paper”.