# Nesting subplots in plot recipes

**URL:** <https://discourse.julialang.org/t/nesting-subplots-in-plot-recipes/26559>\
**Category:** General Usage\
**Tags:** plotting, plots, recipe\
**Created:** [July 19, 2019, 6:41pm UTC](https://discourse.julialang.org/t/nesting-subplots-in-plot-recipes/26559 "2019-07-19T18:41:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grahamas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grahamas/32/3401_2.png) [@grahamas](https://discourse.julialang.org/u/grahamas)\
**Post date:** [July 19, 2019, 6:41pm UTC](https://discourse.julialang.org/t/nesting-subplots-in-plot-recipes/26559/1 "2019-07-19T18:41:22Z")

</div>

Is there a way to “automatically” nest layouts?

```julia
using RecipesBase

@recipe function f(pt::MyPlotType, arr::Array{<:MyDataType})
    layout := GridLayout(size(arr)...)
    for data in arr
       @series begin
           (data,)
       end
    end
end

@recipe function f(data::DataType1)
    # makes one series
end

@recipe function f(data::DataType2)
    # makes two series
end

```

so that plotting a 1x2 array of `DataType1` would create a layout like `@layout [a b]`

whereas plotting a 1x2 array of `DataType2` would create a layout like `@layout [[a; b] [c; d]]`
