✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Legend cut off when downloading png

I’m finding that if I download a png image of a plot on my dash app it cuts off the legend if its a bit longer than normal (see image).
It renders fine on the app but when I click the download plot as png the problem occurs.
I’ve tried playing around with the legend location and the margin of the plot but it makes no difference, even if the legend is in the middle of the plotting area I still get the same problem.

Any help of what I can try would be very appreciated!

Hi @dig, probably your problem is the same as Save plot as png; sizing and positioning (see the last post, you need to set the config of your dcc.Graph

config = {"toImageButtonOptions": {"width": None, "height": None}}
dcc.Graph(figure=..., config=config)

)

I’ve set that and there same problem still occurs - I’ve also tried explicitly setting a height and width to see if I could make the plot big enough but the same problem still occurs.
I’ve got round this for now by just having shorter labels in the legend but not sure thats a long term solution

ok… if you post here a minimal standalone app (with dummy data) reproducing the problem I can take a look.

I can’t seem to recreate the problem with a simple example. Do you think this could be something to do with my CSS layout? The plots are in divs which I’ve made set sizes and I wonder if that could affect the image? Although I would have thought that would just change the rendering on the browser.

I also had the attribute ‘scale’ in the ‘toImageButtonOptions’ set to ‘scale’:2. I’ve played around with that but it doesn’t seem to change the legend either.

@dig Did you ever find a solution to this? I’m having the same issue with svg exports.

Hi @dig , @bigmike , I’m seeing the same issue but wonder similarly if my CSS is having some effect here. Did either of you come up with anything?

Thanks,

Stu

Still no solution to this issue on my end.

Thanks for the update; I might try and raise again elsewhere.