CairoMakie No Copy Button VSCode

Not new to Julia, but new to CairoMakie. Trying to switch my plots from PythonPlots. My old PythonPlots workflow generated an image in VSCode that had a little copy symbol on it, that would copy it to the clipboard. With CairoMakie, if I use “svg”, I get save and pop out into another window buttons (but no copy) and if I CairoMakie.activate!(type = “png”), I get no buttons. All I want is for a simple copy to clipboard functionality. Any tips would be appreciated.

Do you mean pythonplot has a symbol on top of the displayed image? Could you show me what that looks like?

The vscode plot pane has its own option “copy to clipboard” although it is a bit buggy

What I think I mean is the “copy to clipboard” button which displays for inline plots in Jupyter Notebooks in VSCode.

Here is an example with PythonPlot, where the buttons appear.

Here is an example with CarioMakie with type=“png” where no buttons appear (no, hovering does not make them appear).

I can use type=“svg” to get the last two buttons back to appear, but I cannot get the first one, “copy to clipboard” to appear in either case.

Ah that must be because if possible, Makie displays pngs via the text/html MIME type to ensure the correct effective visual size (otherwise with high px_per_unit, images are shown too large). But the notebook frontend only implements the copy button for the png mime type.

You can disable certain MIME types, so you might want to disable text/html if you don’t like this behavior and want the plain png back (which might have sizing issues). Compare to the activation code in CairoMakie, you might need CairoMakie.disable_mime!("svg", "pdf", "text/html") maybe

2 Likes

Thanks so much! That worked and re-enabled functionality as promised. Do you know if copy button functionality might be coming to the text/html type? I can see why it might not.

In principle there could of course be a copy button for html, it’s just less useful in general than the png I guess because that, being a common image format, allows you to paste the content anywhere where an image can be processed, like Photoshop, PowerPoint, etc. while HTML could contain anything, so it will be much less compatible. If browsers respected the physical size metadata of png files, I might not have opted for the current method of inlining the images in a small html snippet, but I find it really annoying if images aren’t sharp and correctly sized, but blurry and huge.