# How to combine Makie plots in a single figure?

**URL:** <https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353>\
**Category:** New to Julia\
**Tags:** question, package, plotting, makie\
**Created:** [August 1, 2023, 2:07pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353 "2023-08-01T14:07:14Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Axze-rgb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/axze-rgb/32/50986_2.png) [@Axze-rgb](https://discourse.julialang.org/u/Axze-rgb)\
**Post date:** [August 1, 2023, 2:07pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/1 "2023-08-01T14:07:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [August 1, 2023, 2:16pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/2 "2023-08-01T14:16:27Z")

</div>

Should be as easy as

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

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/a/5a88d62eb2b52fc60c5d3e41175d647620aaf972.png)

---

<div class="post-metadata">

**Author:** ![Axze-rgb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/axze-rgb/32/50986_2.png) [@Axze-rgb](https://discourse.julialang.org/u/Axze-rgb)\
**Post date:** [August 1, 2023, 2:30pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/3 "2023-08-01T14:30:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 1, 2023, 2:37pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/4 "2023-08-01T14:37:01Z")

</div>

See:

> **[Basic Tutorial · Makie](https://docs.makie.org/stable/tutorials/basic-tutorial/#subplots)**
>
> Learn how to create data visualizations with Makie, the plotting ecosystem for the Julia language, in this introductory tutorial. Topics include Makie's different backends, basic building blocks like Figure, Axis, lines and scatters as well as how to...

---

<div class="post-metadata">

**Author:** ![Axze-rgb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/axze-rgb/32/50986_2.png) [@Axze-rgb](https://discourse.julialang.org/u/Axze-rgb)\
**Post date:** [August 1, 2023, 2:42pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/5 "2023-08-01T14:42:00Z")

</div>

Doesn’t work because of MakieLayout not compiling

---

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [August 1, 2023, 2:50pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/6 "2023-08-01T14:50:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 1, 2023, 2:56pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/7 "2023-08-01T14:56:14Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![Axze-rgb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/axze-rgb/32/50986_2.png) [@Axze-rgb](https://discourse.julialang.org/u/Axze-rgb)\
**Post date:** [August 1, 2023, 3:01pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/8 "2023-08-01T15:01:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Axze-rgb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/axze-rgb/32/50986_2.png) [@Axze-rgb](https://discourse.julialang.org/u/Axze-rgb)\
**Post date:** [August 1, 2023, 3:03pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/9 "2023-08-01T15:03:06Z")

</div>

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](https://file+.vscode-resource.vscode-cdn.net/home/alessandro/Data/MAexperiment/24-07-2023_Deepvariant_standing_variation_analysis_based_on_HiFi/Clair3/~/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”)

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 1, 2023, 3:15pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/10 "2023-08-01T15:15:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Axze-rgb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/axze-rgb/32/50986_2.png) [@Axze-rgb](https://discourse.julialang.org/u/Axze-rgb)\
**Post date:** [August 1, 2023, 3:17pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/11 "2023-08-01T15:17:13Z")

</div>

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

---

<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:** [August 1, 2023, 3:31pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/12 "2023-08-01T15:31:53Z")

</div>

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](http://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.

---

<div class="post-metadata">

**Author:** ![Axze-rgb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/axze-rgb/32/50986_2.png) [@Axze-rgb](https://discourse.julialang.org/u/Axze-rgb)\
**Post date:** [August 1, 2023, 3:34pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/13 "2023-08-01T15:34:37Z")

</div>

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.

---

<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:** [August 1, 2023, 3:36pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/14 "2023-08-01T15:36:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Axze-rgb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/axze-rgb/32/50986_2.png) [@Axze-rgb](https://discourse.julialang.org/u/Axze-rgb)\
**Post date:** [August 1, 2023, 4:00pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/15 "2023-08-01T16:00:41Z")

</div>

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](https://file+.vscode-resource.vscode-cdn.net/home/alessandro/Data/MAexperiment/24-07-2023_Deepvariant_standing_variation_analysis_based_on_HiFi/Clair3/Base.jl:31) [2] top-level scope @ [~/Data/MAexperiment/24-07-2023\_Deepvariant\_standing\_variation\_analysis\_based\_on\_HiFi/Clair3/plotting.ipynb:6](https://file+.vscode-resource.vscode-cdn.net/home/alessandro/Data/MAexperiment/24-07-2023_Deepvariant_standing_variation_analysis_based_on_HiFi/Clair3/~/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

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [August 1, 2023, 4:16pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/16 "2023-08-01T16:16:47Z")

</div>

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:

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

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

```julia
using Pkg
Pkg.activate("~/path/to/your/project/")
Pkg.instantiate()

```

---

<div class="post-metadata">

**Author:** ![Axze-rgb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/axze-rgb/32/50986_2.png) [@Axze-rgb](https://discourse.julialang.org/u/Axze-rgb)\
**Post date:** [August 1, 2023, 4:18pm UTC](https://discourse.julialang.org/t/how-to-combine-makie-plots-in-a-single-figure/102353/17 "2023-08-01T16:18:10Z")

</div>

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