CairoMakie plots disappear once linked to an Illustrator file

Hello everyone,

I’m facing an issue with using CairoMakie and Adobe Illustrator 2025 that I hope someone here can help me with. The workflow involves generating some plots with CairoMakie, linking these plots into Illustrator, and exporting the final composition to a PDF. However, I’ve encountered a strange behavior: the CairoMakie plots seem to disappear in the final exported PDF, while plots generated by PyPlot are displayed correctly.

Here’s a minimal working example that illustrates the problem

using CairoMakie
using PyPlot

x_vec = 0:0.1π:2π
y_vec = sin.(x_vec)

##

m_fig = CairoMakie.Figure()
m_ax = CairoMakie.Axis(m_fig[1, 1], title="CairoMakie")
CairoMakie.lines!(m_ax, x_vec, y_vec)
save("sin_makie.pdf", m_fig)

##

p_fig = PyPlot.figure()
p_ax = p_fig.add_subplot(111)
p_ax.plot(x_vec, y_vec)
p_ax.set_title("PyPlot")
p_fig.savefig("sin_pyplot.pdf")

The generated PDFs are initially rendered correctly when opened individually:

However, after linking both PDFs to a new, empty Illustrator file and exporting that Illustrator composition to PDF (using default export settings), only the PyPlot version remains visible in the resulting PDF when opened in any PDF reader. Meanwhile, in Illustrator itself, both plots are correctly displayed (I colored the background to increase the contrast):

Interestingly, I noticed that if I manually select in Acrobat the approximate area where I expect the CairoMakie plot to be and use the “remove crop” option, the plot suddenly becomes visible again:

This suggests the issue might be related to some kind of cropping or clipping behavior, but I’m unsure why CairoMakie plots exhibit this and PyPlot plots do not.

Has anyone experienced similar behavior with CairoMakie, or have any suggestions on how to adjust figure generation or export settings to avoid this? I suspect this could be related to the way CairoMakie handles layers or clipping paths, but I would really appreciate any insights.

Thank you so much for your help!

Thank you,
Lorenzo

I used to see issues like this with Plots.jl, where there would be weird masks or clipping. Are the images embedded, or linked?

And have you tried SVG export instead of PDF?

Thanks for your answer, Kevin.

Indeed, the problem does not show up when I export as SVG. This, however, has the drawback that the text gets outlined and can’t be selected anymore.
Also, the images are linked and not embedded because I don’t have latex fonts installed on my computer, and if I try to embed the pdf it will complain about the missing fonts.

Anyway, I think I agree with you that the problem is originating by some weird clipping. This, however, should be something fixable from CairoMakie’s side, right?

1 Like

We’re using Cairo so either it’s a bug in how we use it or a bug in Cairo.

One thing that could be helpful to diagnose is to try some of the examples in Cairo.jl, and see if PDFs generated from those exhibit the same problem?

1 Like

Indeed already the first simple example in Cairo.jl shows the same problem.

One thing I would like to try is to use the actual C library and check if I get the error there as well. If so, maybe Cairo’s issue page would be the right place to report it?

Does Cairo expose any PDF settings like the version which one could play around with to see if they make a difference?