You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems indeed that there is currently a bug in GLMakie which prevents one to make figures with transparent background.
I tested it with GalerkinToolkit example:
import GalerkinToolkit as GT
import PartitionedSolvers as PS
import ForwardDiff
import GLMakie
using LinearAlgebra
function ex()
domain = (0,1,0,1)
cells = (10,10)
mesh = GT.cartesian_mesh(domain,cells;simplexify=true)
dirichlet_tag = "dirichlet"
GT.label_boundary_faces!(mesh;physical_name=dirichlet_tag)
Ω = GT.interior(mesh)
Γd = GT.boundary(mesh;physical_names=[dirichlet_tag])
k = 1
V = GT.lagrange_space(Ω,k;dirichlet_boundary=Γd)
uhd = GT.dirichlet_field(Float64,V)
g = GT.analytical_field(x->0,Ω)
f = GT.analytical_field(x->1,Ω)
GT.interpolate_dirichlet!(g,uhd)
dΩ = GT.measure(Ω,2*k)
∇ = ForwardDiff.gradient
a(u,v) = GT.∫( x->∇(u,x)⋅∇(v,x), dΩ)
l(v) = GT.∫( x->v(x)*f(x), dΩ)
p = GT.linear_problem(uhd,a,l)
s = PS.LinearAlgebra_lu(p)
s = PS.solve(s)
uh = GT.solution_field(uhd,s)
bgcolor = :black
fig = Figure(; size = (1500, 1500), backgroundcolor=bgcolor)
scene = LScene(
fig[1, 1],
show_axis=true,
scenekw = (
lights=[],
backgroundcolor=bgcolor,
clear=true,
transparency=true,
),
)
GLMakie.plot!(scene,Ω;color=uh,strokecolor=:black)
fig
end
ex()
But if I set bgcolor = :transparent, The final figure is just a blank white canvas as described in MakieOrg/Makie.jl#4007
The only work around this I could find is to use CairoMakie, like so:
import GalerkinToolkit as GT
import PartitionedSolvers as PS
import ForwardDiff
import CairoMakie
using LinearAlgebra
functionex()
domain = (0,1,0,1)
cells = (10,10)
mesh = GT.cartesian_mesh(domain,cells;simplexify=true)
dirichlet_tag ="dirichlet"
GT.label_boundary_faces!(mesh;physical_name=dirichlet_tag)
Ω = GT.interior(mesh)
Γd = GT.boundary(mesh;physical_names=[dirichlet_tag])
k =1
V = GT.lagrange_space(Ω,k;dirichlet_boundary=Γd)
uhd = GT.dirichlet_field(Float64,V)
g = GT.analytical_field(x->0,Ω)
f = GT.analytical_field(x->1,Ω)
GT.interpolate_dirichlet!(g,uhd)
dΩ = GT.measure(Ω,2*k)
∇ = ForwardDiff.gradient
a(u,v) = GT.∫( x->∇(u,x)⋅∇(v,x), dΩ)
l(v) = GT.∫( x->v(x)*f(x), dΩ)
p = GT.linear_problem(uhd,a,l)
s = PS.LinearAlgebra_lu(p)
s = PS.solve(s)
uh = GT.solution_field(uhd,s)
bgcolor =:transparent
fig =Figure(; size = (1500, 1500), backgroundcolor=bgcolor)
scene =LScene(
fig[1, 1],
show_axis=true,
scenekw = (
lights=[],
backgroundcolor=bgcolor,
clear=true,
transparency=true,
),
)
CairoMakie.plot!(scene,Ω;color=uh,strokecolor=:black)
fig
endex()
I am not sure if this is an options for us ? If yes, I need to investigate how to include a LScene into our custom GalerkinToolkit Makie plots which for what I could experience so far is not so straightforwards as I initially thought.
The text was updated successfully, but these errors were encountered:
Does CairoMakie also work for 3d plots? and for creating animations?
Hi @fverdugo. It does make 2D and 3D plots, although it looks like the quality of these latter is slightly lower than GLMakie. However, as CairoMakie is expected to generate png-like figures, they are not iterative. The good thing is that we can use both packages at our convenience.
I will show you latter today how the documentation would look like with transparent plots done with CairoMakie.
@fverdugo and @raar1. While investigating this possibility I came across the following issue in the official
Makie.jl
repo: MakieOrg/Makie.jl#4007It seems indeed that there is currently a bug in
GLMakie
which prevents one to make figures with transparent background.I tested it with
GalerkinToolkit
example:But if I set
bgcolor = :transparent
, The final figure is just a blank white canvas as described in MakieOrg/Makie.jl#4007The only work around this I could find is to use
CairoMakie
, like so:I am not sure if this is an options for us ? If yes, I need to investigate how to include a
LScene
into our custom GalerkinToolkit Makie plots which for what I could experience so far is not so straightforwards as I initially thought.The text was updated successfully, but these errors were encountered: