# Makie col/rowsize for grid, unexpected(?) behaviour

**URL:** https://discourse.julialang.org/t/makie-col-rowsize-for-grid-unexpected-behaviour/114671
**Category:** Visualization
**Tags:** plotting, makie, glmakie
**Created:** [May 24, 2024, 9:56am UTC](https://discourse.julialang.org/t/makie-col-rowsize-for-grid-unexpected-behaviour/114671 "2024-05-24T09:56:43Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)
#### Post date: [May 24, 2024, 9:56am UTC](https://discourse.julialang.org/t/makie-col-rowsize-for-grid-unexpected-behaviour/114671/1 "2024-05-24T09:56:43Z")

</div>

Greetings everyone,

Suppose we have the following figure in GLMakie:

```julia
using GLMakie

f = Figure()

Axis(f[1, 1])
Axis(f[2, 1])
Axis(f[2, 2])

colsize!(f.layout, 1, Fixed(300))
rowsize!(f.layout, 2, Fixed(300))
rowsize!(f.layout,1,Aspect(1,0.2))
colsize!(f.layout,2,Aspect(1,1))
f

```

Here, everything works perfectly fine.

However, if I try to do the same “col/rowsize treatment” on axes that are part of a grid layout, as follows, I get an error saying “row 2 is invalid”.

```julia
f = Figure()
m = f[1,1]
n = f[1,2]

Axis(m[1, 1])
Axis(m[2, 1])
Axis(m[2, 2])

Axis(n[1,1])

colsize!(m.layout, 1, Fixed(300))
rowsize!(m.layout, 2, Fixed(300))
rowsize!(m.layout,1,Aspect(1,0.2))
colsize!(m.layout,2,Aspect(1,1))

```

What would be the correct way to do this?

Also, I was wondering whether I could avoid using fixed col and row sizes and achieve the same behaviour with relative sizes (bottom left plot should be square). Any suggestions would be appreciated!

---

<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, 2024, 7:23am UTC](https://discourse.julialang.org/t/makie-col-rowsize-for-grid-unexpected-behaviour/114671/2 "2024-05-27T07:23:31Z")

</div>

`m` is not a `GridLayout`, you’d need to instantiate that on its own to mutate it:

```julia
f = Figure()
m = GridLayout(f[1,1])
n = f[1,2]

Axis(m[1, 1])
Axis(m[2, 1])
Axis(m[2, 2])

Axis(n[1,1])

colsize!(m, 1, Fixed(300))
rowsize!(m, 2, Fixed(300))
rowsize!(m,1,Aspect(1,0.2))
colsize!(m,2,Aspect(1,1))
f

```

To your other question, you can use `Aspect` referencing a `Relative` for example, although `Aspect` is not great in interactively resized windows when you either make width much larger than height, or the other way around.

```julia
f = Figure()

Axis(f[1, 1])
Axis(f[2, 1])
Axis(f[2, 2])

colsize!(f.layout, 1, Relative(0.6))
rowsize!(f.layout,2,Aspect(1, 1))
f

```

---

<div class="post-metadata">

### Author: ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)
#### Post date: [May 27, 2024, 7:54am UTC](https://discourse.julialang.org/t/makie-col-rowsize-for-grid-unexpected-behaviour/114671/3 "2024-05-27T07:54:19Z")

</div>

Excellent, thanks a lot for clarifying!  
Also, would there be a way in this case to save only one part of the layout?  
Something like `Makie.save("plot.png", m)`  
(which doesn’t work here).

---

<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, 2024, 10:43am UTC](https://discourse.julialang.org/t/makie-col-rowsize-for-grid-unexpected-behaviour/114671/4 "2024-05-27T10:43:04Z")

</div>

Not really, because content can in principle overlap into neighboring areas, even though that usually looks bad. You could write some code that checks the boundaries of some subgridlayout you’re interested in and crops the full image or svg to that area.

---

<div class="post-metadata">

### Author: ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)
#### Post date: [May 27, 2024, 10:48am UTC](https://discourse.julialang.org/t/makie-col-rowsize-for-grid-unexpected-behaviour/114671/5 "2024-05-27T10:48:43Z")

</div>

Understood, thanks for the reply!  
I reckon in this case it might be better to create an extra figure with the desired content only, and save that instead.
