Makie - SVG saved with CairoMakie not editable (looks like raster)

Hi guys,

I am using CairoMakie on Ubuntu and saving plots as SVG.

When I open the SVG file with Inkscape to edit it, the file cannot be edited. It looks like a raster image. What is happening?

At first glance, this may seem like an Inkscape question, but I already checked with other SVG files and I can edit them with Inkscape. I also tried many tricks in Inkscape to make the CairoMakie-saved SVG files editable, without success.

So the problem is that SVG files saved using CairoMakie cannot be edited because they seem to be raster. I cannot access the different objects and paths. It only allows me to change the center of the SVG file. Do you have any idea?

Thank you.

I have the same problems when saving as svg even if I run CairoMakie.activate!(type = "svg"). However, a fine workaround is to save as pdf and then open the pdf in Inkscape. That provides you with a vector format.

1 Like

Hey, thank you for the suggestion.

Do you know if something can be done in the long-run? It is very sad, to say the least.

I would suggest reporting a bug. It is probably just some silly omission in the save code. I am not particularly worried, as the exact format (pdf or svg) does not matter much to me, as long as it is actually a vector format (which it is in the case of pdf).

Sure, I think I will do it. Thanks so much for your help.

1 Like

What plot objects are you using? There are certain operations where cairo just falls back to rasterization and svg supports a different subset than pdf

1 Like

I am using lines and density, at least. They all produce rasters…

BUT, previously the same plots (using lines and density) were properly saved as SVG. Suddenly something happened, and they began to be saved as rasters.

That is why I was so confused. I did not change anything in my code and plots began to be saved as rasters. I think I installed a few packages, and I updated Ubuntu, but that is all. I guess maybe those packages changed something ?

Hm density drops down to poly, might drop down to mesh. If dispatch in CairoMakie changed again so mesh is hit, that could cause rasterization. Can you leave out density and check if it’s fine?

It does not seem to work with lines only.

using CairoMakie

t = collect(0:100)
d = rand(100)

p = lines(t,d)

I’ll check it out later, something is fishy then. But just to make sure, this happens with save("test.svg", fig) or only with displaying in VSCode or something comparable?

When I save it as svg. Here is the whole thing.

using CairoMakie

t = collect(0:100)
d = rand(101)

p = lines(t,d)

save("/home/vmh/Downloads/example.svg",p)

That produces png for me. Near the top of the file is

<image id="image5-bdBTEqB/" width="2500" height="1876" xlink:href="data:image/png;base64,

Ok then something added relatively recently to CairoMakie must be incompatible with svgs, I’ll have to check that out later

Appreciate it. I think Makie is a fantastic framework for plotting in Julia. Thank you @jules