# How do I make background in Makie transparent

**URL:** <https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958>\
**Category:** General Usage\
**Tags:** plotting, makie\
**Created:** [May 27, 2021, 8:04pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958 "2021-05-27T20:04:56Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wei\_Yang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wei_yang/32/23951_2.png) [@Wei\_Yang](https://discourse.julialang.org/u/Wei_Yang)\
**Post date:** [May 27, 2021, 8:04pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958/1 "2021-05-27T20:04:57Z")

</div>

I’m trying to get plots with transparent (nothing at all) background in Makie

```julia
using GLMakie
F = Figure()
ax = Axis(F[1,1])
θ = 0:0.1:2pi
X = cos.(θ)
Y = sin.(θ)
lines!(X,Y)
hidespines!(ax)
hidedecorations!(ax)

save("icon.png",F)

```

The saved file has a white background, is there anyway to make the background transparent (no background).

 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/2/f21c1a4760e493d51d09be0328b2a4ca5b85c08c.png)

---

<div class="post-metadata">

**Author:** ![Wei\_Yang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wei_yang/32/23951_2.png) [@Wei\_Yang](https://discourse.julialang.org/u/Wei_Yang)\
**Post date:** [May 27, 2021, 8:24pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958/2 "2021-05-27T20:24:47Z")

</div>

In Plots.jl one can do,

```julia
using Plots
θ = 0:0.1:2pi
X = cos.(θ)
Y = sin.(θ)
p=plot(X,Y, background_color=:transparent,
        legend = false,ticks=false, axis=false)
savefig(p, "test.png") 

```

![test](https://global.discourse-cdn.com/julialang/original/3X/d/6/d665c3330f4af9b70e43e581c6a68264fb7c5433.png)  
really want to know how to do this in Makie 📖🤦‍♂️

---

<div class="post-metadata">

**Author:** ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Post date:** [May 27, 2021, 8:29pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958/3 "2021-05-27T20:29:44Z")

</div>

I am not certain this will work, but could you try:

```julia
ax = Axis(F[1,1], backgroundcolor=(:white,0))

```

Usually the element after the color is the alpha of the channel in other parts of Makie.

---

<div class="post-metadata">

**Author:** ![Wei\_Yang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wei_yang/32/23951_2.png) [@Wei\_Yang](https://discourse.julialang.org/u/Wei_Yang)\
**Post date:** [May 27, 2021, 8:30pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958/4 "2021-05-27T20:30:56Z")

</div>

> [@aramirezreyes](#):
>
> `ax = Axis(F[1,1], backgroundcolor=(:white,0))`

Unfortunately it does not work😭.

---

<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:** [May 27, 2021, 8:46pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958/5 "2021-05-27T20:46:53Z")

</div>

The figure needs a transparent background, maybe `Figure(backgroundcolor = :transparent)` and `Axis(backgroundcolor = :transparent)` together?

---

<div class="post-metadata">

**Author:** ![Wei\_Yang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wei_yang/32/23951_2.png) [@Wei\_Yang](https://discourse.julialang.org/u/Wei_Yang)\
**Post date:** [May 27, 2021, 8:52pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958/6 "2021-05-27T20:52:11Z")

</div>

😭sadly no.

I also tried to set both to `(:white,0)` , and other combinations of the two, they all failed. 😥

---

<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:** [May 27, 2021, 9:01pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958/7 "2021-05-27T21:01:06Z")

</div>

Maybe that’s a problem with the background in GLMakie @sdanisch ? I think it should be no problem in CairoMakie to get a fully transparent background

---

<div class="post-metadata">

**Author:** ![Wei\_Yang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wei_yang/32/23951_2.png) [@Wei\_Yang](https://discourse.julialang.org/u/Wei_Yang)\
**Post date:** [May 27, 2021, 9:12pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958/8 "2021-05-27T21:12:04Z")

</div>

I tried CairoMakie, and didn’t work, maybe I’m doing something wrong😥

```julia
using CairoMakie
# if, for example, GLMakie is activated already
CairoMakie.activate!()
F = Figure(backgroundcolor = :transparent)
ax = Axis(F[1,1], backgroundcolor = :transparent)
θ = 0:0.1:2pi
X = cos.(θ)
Y = sin.(θ)
lines!(X,Y)
hidespines!(ax)
hidedecorations!(ax)

save("1221344.png",F)

```

---

<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:** [May 27, 2021, 9:28pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958/9 "2021-05-27T21:28:25Z")

</div>

for me it worked

```julia
using CairoMakie
f = Figure(backgroundcolor = :transparent)

Axis(f[1, 1], backgroundcolor = :transparent)
lines!(1:10)

save("test.png", f)

```

 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/6/7/6753b8f419782d6d7bc257d1d378c2336fbcbb62.jpeg)

---

<div class="post-metadata">

**Author:** ![Wei\_Yang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wei_yang/32/23951_2.png) [@Wei\_Yang](https://discourse.julialang.org/u/Wei_Yang)\
**Post date:** [May 27, 2021, 9:32pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958/10 "2021-05-27T21:32:04Z")

</div>

YES!!! This works!!! (After I restarted the kernel in Jupiter Lab)

---

<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:** [May 27, 2021, 9:33pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958/11 "2021-05-27T21:33:24Z")

</div>

nice, I’ll check why it doesn’t work in glmakie

---

<div class="post-metadata">

**Author:** ![Wei\_Yang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wei_yang/32/23951_2.png) [@Wei\_Yang](https://discourse.julialang.org/u/Wei_Yang)\
**Post date:** [May 27, 2021, 9:42pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958/12 "2021-05-27T21:42:34Z")

</div>

> [@aramirezreyes](#):
>
> `(:white,0)`

Setting `backgroundcolor` in both `Figure` and `Axis` to `(:white,0)` has the same effect as `:transparent` in CairoMakie, they worked 😊 (failed in GLMakie 😥)

```julia
F = Figure(backgroundcolor = (:white,0))

ax = Axis(F[1, 1], backgroundcolor =(:white,0))

```

---

<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:** [February 26, 2024, 3:18pm UTC](https://discourse.julialang.org/t/how-do-i-make-background-in-makie-transparent/61958/13 "2024-02-26T15:18:17Z")

</div>

For anyone finding this thread, there’s a workaround for GLMakie even if it cannot have transparent backgrounds natively

[https://docs.makie.org/stable/how-to/save-figure-with-transparency/](https://docs.makie.org/stable/how-to/save-figure-with-transparency/)
