Link X axes of different dcc.Graphs (not subplots)

Hi,

It’s been 6 months that I’m using plotly and dash in order to create interactive data visualisation tools.
I first started with plotly subplots, but I was not satisfied by the contraints of the “make_subplot” fonction (for example not being able to display each legend next to a specific subplots)

Therefore, I decided to use independant graphs (one beneath one another).
But there are 2 “subplot” features that I would like to re-create (but did not succeed so far):

  • shared_axis :
    I managed to create a kind of buggy alternative solution with a callback using relayout_data but I’m not entirely satisfied by it.

  • same plot width no matter the legend’s width :
    Currently, the plot’s width is automatically computed according to the screen size and the legend’s width. As a consequence, when 2 graphs have different legends, the graph’s widths are different. I want them to be equal no matter the legend’s width (just like in real subplots). The only way I found to have all my graphs perfeclty lined up is to set the legend’s width to a constant, that won’t be adapted for each screen size.

Maybe I’m missing some Dash important functions, let me know if you have some workarounds in mind ! :slight_smile:

Is the discussion at this link any help for the first question?

On the second, if it’s possible to set the legend to a fixed width, is it also possible to have that width respond to viewport width using a CSS media query?

Thanks David !

The link you gave me is very nice! I was missing the “Patch()” fonction!
For some reasons, the callback is sometime not triggered by a double click on graphs (reset), but I will look into it!

For the CSS solution, I’m quite new to CSS. I tried this approach but I did not manage to compute a width based on the largest legend and then apply it to all the others

That sounds like a harder problem than the one I thought you were trying to solve - I don’t think you can do that in CSS. Might be possible with Javascript.