# Plot @layout adjust width of grid

**URL:** https://discourse.julialang.org/t/plot-layout-adjust-width-of-grid/72527
**Category:** General Usage
**Tags:** plots, layout-plots
**Created:** [December 3, 2021, 3:19pm UTC](https://discourse.julialang.org/t/plot-layout-adjust-width-of-grid/72527 "2021-12-03T15:19:25Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![evolbio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evolbio/32/30793_2.png) [@evolbio](https://discourse.julialang.org/u/evolbio)
#### Post date: [December 3, 2021, 3:19pm UTC](https://discourse.julialang.org/t/plot-layout-adjust-width-of-grid/72527/1 "2021-12-03T15:19:25Z")

</div>

My goal is a layout like:

@layout [grid(4,2) [b; c{0.166h}; d{0.166h}; e{0.166h}]]

which is a 4 x 2 grid on the left and a stack of 4 plots on the right. However, I want the left 4 x 2 grid to be 1/3 of the total width and the right stack to be 2/3 of the total width. I cannot get that to work. Any advice?

---

<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: [December 3, 2021, 3:47pm UTC](https://discourse.julialang.org/t/plot-layout-adjust-width-of-grid/72527/2 "2021-12-03T15:47:29Z")

</div>

Here’d be one solution for Makie.jl as a fallback, I don’t know how to do it in Plots either:

```julia
f = Figure()
axs_left = [Axis(f[1, 1][i, j]) for i in 1:4, j in 1:2]
axs_right = [Axis(f[1, 2][i, 1]) for i in 1:4]
colsize!(f.layout, 1, Relative(1/3))
f

```

 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/b/4/b4435e6a3b83435ce8fbacc9b1dda448b4ee1b16.png)

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [December 3, 2021, 4:16pm UTC](https://discourse.julialang.org/t/plot-layout-adjust-width-of-grid/72527/3 "2021-12-03T16:16:54Z")

</div>

The OP’s example seems a bit more complex but the equivalent of @jules’ code in Plots.jl might be:

```julia
using Plots; gr(size=(1200,800), dpi=600)
h = fill(1/4, 4)
w = [1/6, 1/6, 2/3]
l = @layout [grid(4,3, heights=h, widths=w)]
p = fill(plot(), 4*3)
plot(p..., layout=l, framestyle=:box)

```

 ![Plots_grid_layout](https://global.discourse-cdn.com/julialang/original/3X/0/f/0f5f6311b057e86237578de8d722c10a89e90c62.png)

---

<div class="post-metadata">

### Author: ![evolbio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evolbio/32/30793_2.png) [@evolbio](https://discourse.julialang.org/u/evolbio)
#### Post date: [December 3, 2021, 4:50pm UTC](https://discourse.julialang.org/t/plot-layout-adjust-width-of-grid/72527/5 "2021-12-03T16:50:45Z")

</div>

Thanks, it is helpful to see how to modify the grid with optional heights and widths. However, what I am trying to do start with the following picture and then shrink the width of the 4x2 grid on the left and expand the width of the column on the right. Still don’t see how to do that.

 ![Screen Shot 2021-12-03 at 8.48.08 AM](https://global.discourse-cdn.com/julialang/original/3X/d/2/d23ac04c7d50c9361446df838a5a54d9b9e503be.jpeg)

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [December 3, 2021, 5:00pm UTC](https://discourse.julialang.org/t/plot-layout-adjust-width-of-grid/72527/6 "2021-12-03T17:00:37Z")

</div>

Using Plots.jl:

```julia
using Plots; gr(size=(1200,800), dpi=600)
l = @layout [grid(4, 2){0.33w} [b; c{0.166h}; d{0.166h}; e{0.166h}] ]
p = fill(plot(), 4*3)
plot(p..., layout=l, framestyle=:box)

```

 ![Plots_grid_layout2](https://global.discourse-cdn.com/julialang/original/3X/4/d/4d82fa2eafc243cc6f9bb69d2a569d509305f4b7.jpeg)

---

<div class="post-metadata">

### Author: ![evolbio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evolbio/32/30793_2.png) [@evolbio](https://discourse.julialang.org/u/evolbio)
#### Post date: [December 4, 2021, 11:33am UTC](https://discourse.julialang.org/t/plot-layout-adjust-width-of-grid/72527/7 "2021-12-04T11:33:27Z")

</div>

> [@rafael.guerra](#):
>
> ```julia
> using Plots; gr(size=(1200,800), dpi=600)
> l = @layout [grid(4, 2){0.33w} [b; c{0.166h}; d{0.166h}; e{0.166h}] ]
> p = fill(plot(), 4*3)
> plot(p..., layout=l, framestyle=:box)
> 
> ```

That worked. Thank you. I had tried various ways of adding the {w} spec before but must have input that modifier incorrectly. In any case, your solution shows the elegance of the @layout notation.
