How to combine Makie plots in a single figure?

Hello,
I really love Makie for all the nice decisions it takes automatically such as great color palettes. That being said, I can’t follow the layout tutorial because Makielayout doesn’t compile, I have been waiting for 2 hours, which I assumed is a sign of an issue.

I am not interested in making ultra complex subplots, I just want plot A next to plot B. There must be a “pure” Julian trick to do that, right?

R has a package called patchwork where you can literally codes “fig1 + fig2” to get the two next to each other. What’s the most convenient approach? In the worse case, I could pass my Julia objects to R so it makes the panel for me, right?

Thanks

Should be as easy as

julia> f = Figure()

julia> plot!(Axis(f[1,1]), 1:10)
Scatter{Tuple{Vector{Point{2, Float32}}}}

julia> plot!(Axis(f[1,2]), 2:11)
Scatter{Tuple{Vector{Point{2, Float32}}}}

1 Like

Sorry, can you explain the code magic behind this black sorcery?

How does Julia understand? I get with f = Figure() we make an object that will hold the graphs, rights?
But then, when you actually plot, how does it know how to arrange them?

And also,I don’t see you needing to call “f” at the end.

Thanks a lot

See:

1 Like

Doesn’t work because of MakieLayout not compiling

What do you mean it is not compiling? That should not be an issue, can you post your error message?

What does MakieLayout have to do with this? The example I linked to in the docs is

using CairoMakie

x = LinRange(0, 10, 100)
y = sin.(x)

fig = Figure()
lines(fig[1, 1], x, y, color = :red)
lines(fig[1, 2], x, y, color = :blue)
lines(fig[2, 1:2], x, y, color = :green)

fig

which doesn’t use MakieLayout?

1 Like

There is a tuto with it, I just confused the two tabs … not glorious ^^’

That said your code returns

UndefVarError: Figure not defined Stacktrace: [1] top-level scope @ ~/Data/MAexperiment/24-07-2023_Deepvariant_standing_variation_analysis_based_on_HiFi/Clair3/plotting.ipynb:6

And I don’t understand why, I have had this issue with Figure not defined today, everything worked well before (yesterday)

Adding context, this doesn’t return any issue

using CairoMakie

using CairoMakie.FileIO

using GLMakie

using CSV

using DataFrames

#cd(“/home/alessandro/Data/MAexperiment/24-07-2023_Deepvariant_standing_variation_analysis_based_on_HiFi/Clair3”)

using Pkg

pkg.add(“FileIO”)

using FileIO

pkg.add(“AbstractPlotting”)

I feel like we’ve had a similar discussion a few days ago - do you have anything else imported which exports Figure? I’ve just copy/pasted the example from the docs which I posted above and it runs without error.

You are totally right and it is what drives me INSANE. I don’t have, unless Julia remembers between restarts of Visual Studio?

EDIT: I shared literally ALL that is in my visual Studio, I promise.

Also, thank you for your patience and kindness dealing with this

EDIT2: even rebooted the computer, same error. I don’t understand what “else” could be lurking around and using Figure

You should not install MakieLayout or AbstractPlotting. Those were part of Makie years ago but will only get you ancient versions or compilation errors now. Any tutorial you see using those is outdated. Check if you’re on the actual docs page docs.makie.org or on the juliahub package docs copy of an old version. Those tend to get ranked high on Google for some reason.

1 Like

Thanks! So I need to get rid of all traces of those packages from my system, right?

Thanks again. It’s annoying those packages keep popping up. Maybe the devs should put an “warning outdated tutorials” on the Makie website? I know it’s probably low on their priority list, though.

I think the last version of AbstractPlotting actually has such a warning. We don’t control the juliahub copies though.

Yeah delete everything but Makie, CairoMakie, GLMakie or WGLMakie from your environment and then update it and you should be good to go. You don’t need to go hunting for file traces or anything, the environment entry is what matters. You can always find the latest versions in the footnote of the docs, so you can compare with those what you have. st in the package repl gives you that info

2 Likes

So I uninstalled Julia completely

then

using Pkg

Pkg.add(“CairoMakie”)

Pkg.add(“GLMakie”)

Pkg.add(“Makie”)

Pkg.add(“CSV”)

Pkg.add(“DataFrames”)

and now

Pkg.update()

and I still get

UndefVarError: Figure not defined Stacktrace: [1] getproperty(x::Module, f::Symbol) @ Base ./Base.jl:31 [2] top-level scope @ ~/Data/MAexperiment/24-07-2023_Deepvariant_standing_variation_analysis_based_on_HiFi/Clair3/plotting.ipynb:6

EDIT: it works in the REPL, not in visual studio, so maybe visual studio keeps stuff. What do you guys use? I am mainly doing plots, exploring data, not much programming per se. Thanks

It’s possible that you have VSCode pointed to an old version of Julia with a different package environment. That said, it’s recommended to keep separate package environments for each project so you don’t end up with dependencies tangled like this. You can make sure you’re in a project-specific environment by doing this at the top of your notebook:

using Pkg
Pkg.activate("~/path/to/your/project/")
Pkg.status()

and you should see the list of packages you’re trying to use. If they don’t show up, you can do

Pkg.add(["APackage", "AnotherPackage", "ThirdPackage"])

to add them to that specific environment. If you navigate to your project directory (~/path/to/your/project/), you’ll see a file called Project.toml that tells Julia which packages you’re asking for. If you switch versions of Julia, you can reinstall those packages by doing

using Pkg
Pkg.activate("~/path/to/your/project/")
Pkg.instantiate()
1 Like

Thanks! somehow it’s reminiscent of the way you keep stuff separate with conda.