Missing legend when exporting to PNG and SVG (Plot)

When I export a cell containing vis created in Observable Plot to PNG or SVG. The downloaded file doesn’t include the legend. Here’s the what I did in an example notebook.

Screenshot of the notebook cell

Downloaded file

1 Like

This happens because the output is not a single SVG but, rather a <figure> containing a DIV for the legend and an SVG for the plot. This is a well known issue and I doubt the behavior will change anytime soon. If you want a PNG, I recommend you simply take a screen shot, which should work well on just about any operating system these days. If you want and SVG, I recommend that you embed the output in a webpage and then print it from Chrome.

IMO it would be great if this could be a browser feature… selecting a clip region and copying it to vector graphics should be a standard thing, not something that every website owner should have to implement against web standards.

I have an experimental converter from html to svg that works for Plot legends, but I haven’t pursued because it was a bit complicated and not fully reliable. I noticed another, similar, issue: when the chart contains “tainted” images, the export menu fails.