# Displaying images in a grid layout?

**URL:** https://discourse.julialang.org/t/displaying-images-in-a-grid-layout/100919
**Category:** Signal and Image Processing
**Created:** [June 28, 2023, 12:01am UTC](https://discourse.julialang.org/t/displaying-images-in-a-grid-layout/100919 "2023-06-28T00:01:32Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![amca01](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amca01/32/5853_2.png) [@amca01](https://discourse.julialang.org/u/amca01)
#### Post date: [June 28, 2023, 12:01am UTC](https://discourse.julialang.org/t/displaying-images-in-a-grid-layout/100919/1 "2023-06-28T00:01:32Z")

</div>

What I’m after is a Julia equivalent to Matlab’s “subplots”, that allows images to be displayed in arbitrary grids. I can “stitch” two images of the same size with

```
[img1 img2]

```

as the last line of an IJulia cell. But this shows the two images as one single, larger image, which is not what I want. I’m looking for something like

```
plot(img1, img2, layout=(1,2)) 

```

in which the sizes of the two images are irrelevant. The best I can find so far is

```
plot(plot(img1,seriestype=:image),plot(img2,seriestype=:image))

```

but this resizes the images so that they’re displayed with the same size. Again, that’s not quite what I want.

What’s my best option here?

Thanks,  
Alasdair

---

<div class="post-metadata">

### Author: ![JohnnyChen94](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnnychen94/32/29979_2.png) [@JohnnyChen94](https://discourse.julialang.org/u/JohnnyChen94)
#### Post date: [June 28, 2023, 12:56am UTC](https://discourse.julialang.org/t/displaying-images-in-a-grid-layout/100919/2 "2023-06-28T00:56:51Z")

</div>

[MosaicViews.jl](https://github.com/JuliaArrays/MosaicViews.jl) provided a helper function `mosaic` for this feature. This package [is reexported by ImageCore](https://github.com/JuliaImages/ImageCore.jl/blob/d7c472211a9419b35525c6454fef56206426176d/src/ImageCore.jl#L8) so `using ImageCore` also gives you `mosaic`.

---

<div class="post-metadata">

### Author: ![gcalderone](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gcalderone/32/1539_2.png) [@gcalderone](https://discourse.julialang.org/u/gcalderone)
#### Post date: [June 28, 2023, 8:41am UTC](https://discourse.julialang.org/t/displaying-images-in-a-grid-layout/100919/3 "2023-06-28T08:41:15Z")

</div>

If [Gnuplot.jl](https://gcalderone.github.io/Gnuplot.jl/v1.4.1/) is an option, you may try:

```julia
using Gnuplot
img1 = randn(100, 200);
img2 = randn(150, 50);
@gp "set multiplot layout 1,2" "set autoscale fix" "set size ratio -1" :-
@gp :- 1 img1 "w image notit" 2 img2 "w image notit"

```

which would produce the following:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/3/73adadb857a0ec277d616628833944aef7c042a7.png)

Further info [here](https://gcalderone.github.io/Gnuplot.jl/v1.4.1/advanced/#Multiplot).

---

<div class="post-metadata">

### Author: ![amca01](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amca01/32/5853_2.png) [@amca01](https://discourse.julialang.org/u/amca01)
#### Post date: [June 29, 2023, 12:06am UTC](https://discourse.julialang.org/t/displaying-images-in-a-grid-layout/100919/4 "2023-06-29T00:06:29Z")

</div>

Many thanks - it does seem that mosaicview works well, especially if you use the `npad` and `fillvalue` options.
