# CairoMakie plots disappear once linked to an Illustrator file

**URL:** https://discourse.julialang.org/t/cairomakie-plots-disappear-once-linked-to-an-illustrator-file/122492
**Category:** Visualization
**Tags:** cairomakie
**Created:** [November 11, 2024, 10:24am UTC](https://discourse.julialang.org/t/cairomakie-plots-disappear-once-linked-to-an-illustrator-file/122492 "2024-11-11T10:24:33Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![LorenzoFioroni](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lorenzofioroni/32/213290_2.png) [@LorenzoFioroni](https://discourse.julialang.org/u/LorenzoFioroni)
#### Post date: [November 11, 2024, 10:24am UTC](https://discourse.julialang.org/t/cairomakie-plots-disappear-once-linked-to-an-illustrator-file/122492/1 "2024-11-11T10:24:34Z")

</div>

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

```julia
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:

 ![pdfs_individually_rendered_correctly](https://global.discourse-cdn.com/julialang/original/3X/e/a/ea1b838c9430f67a39f1e95a4fc3e767528d93c5.png)

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):

 ![correctly_rendered_in_illustrator.pdf](https://global.discourse-cdn.com/julialang/original/3X/e/c/ecb9032d6567e377fb1f1b1c32e7f8f45d942b0f.png)  
 ![problematic_rendering_in_acrobat](https://global.discourse-cdn.com/julialang/original/3X/7/7/77ce3f70b6ffe7b501047b9904d0b8c24225f080.png)

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:

 ![edit_menu_in_acrobat](https://global.discourse-cdn.com/julialang/original/3X/c/a/ca8f358800c9bc591007718a3d1df75f0aafb60e.png)  
 ![plot_visible_again_after_remove_crop](https://global.discourse-cdn.com/julialang/original/3X/9/5/95124cf22a5a9c4a211ba3ef29889d60044cd5f7.png)

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

---

<div class="post-metadata">

### Author: ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)
#### Post date: [November 11, 2024, 2:26pm UTC](https://discourse.julialang.org/t/cairomakie-plots-disappear-once-linked-to-an-illustrator-file/122492/2 "2024-11-11T14:26:01Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![LorenzoFioroni](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lorenzofioroni/32/213290_2.png) [@LorenzoFioroni](https://discourse.julialang.org/u/LorenzoFioroni)
#### Post date: [November 11, 2024, 2:56pm UTC](https://discourse.julialang.org/t/cairomakie-plots-disappear-once-linked-to-an-illustrator-file/122492/3 "2024-11-11T14:56:28Z")

</div>

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](https://juliahub.com/ui/Packages/General/CairoMakie)’s side, right?

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [November 11, 2024, 4:25pm UTC](https://discourse.julialang.org/t/cairomakie-plots-disappear-once-linked-to-an-illustrator-file/122492/4 "2024-11-11T16:25:55Z")

</div>

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

---

<div class="post-metadata">

### Author: ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)
#### Post date: [November 12, 2024, 5:12am UTC](https://discourse.julialang.org/t/cairomakie-plots-disappear-once-linked-to-an-illustrator-file/122492/5 "2024-11-12T05:12:10Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![LorenzoFioroni](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lorenzofioroni/32/213290_2.png) [@LorenzoFioroni](https://discourse.julialang.org/u/LorenzoFioroni)
#### Post date: [November 14, 2024, 1:16pm UTC](https://discourse.julialang.org/t/cairomakie-plots-disappear-once-linked-to-an-illustrator-file/122492/6 "2024-11-14T13:16:05Z")

</div>

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](https://gitlab.freedesktop.org/cairo/cairo/-/issues) would be the right place to report it?

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [November 14, 2024, 1:29pm UTC](https://discourse.julialang.org/t/cairomakie-plots-disappear-once-linked-to-an-illustrator-file/122492/7 "2024-11-14T13:29:06Z")

</div>

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