# How to take two exisitng plots and inset one inside the other

**URL:** <https://discourse.julialang.org/t/how-to-take-two-exisitng-plots-and-inset-one-inside-the-other/101226>\
**Category:** General Usage\
**Tags:** plotting, plots, gr\
**Created:** [July 5, 2023, 7:25pm UTC](https://discourse.julialang.org/t/how-to-take-two-exisitng-plots-and-inset-one-inside-the-other/101226 "2023-07-05T19:25:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NegativeOne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/negativeone/32/51279_2.png) [@NegativeOne](https://discourse.julialang.org/u/NegativeOne)\
**Post date:** [July 5, 2023, 7:25pm UTC](https://discourse.julialang.org/t/how-to-take-two-exisitng-plots-and-inset-one-inside-the-other/101226/1 "2023-07-05T19:25:37Z")

</div>

In want to take the outputs of two separate plot commands and inset one inside the other.  
I’m using the GR backend.  
I have two plots, one created as

```julia
p = plot(t, cohs, lw=[3 1 1 1 1], ls=[:solid :dash :dash :dash :dash])
vline!(p, [K*δt], label="Memory Cutoff")

```

- `t` is just a vector of length `N`
- `cohs` is a `Nx5` matrix of Float64s

and the other

```julia
inset_plot = plot(cutoffs, y, xscale=:log10, xflip=true, legend=false)

```

I want to inset the second inside the first. For example,

 ![inset_example](https://global.discourse-cdn.com/julialang/original/3X/c/3/c3b0a52f73fe318476559ce49d95e0b3ac1cec66.png)

The closest I got is by combining the two commands into one

```julia
layout = bbox(0.1, 0.1, 0.5, 0.5, :right)

plot([t, cutoffs], [cohs, y]; 
  lw=[3 1 1 1 1], 
  ls=[:solid :dash :dash :dash :dash], 
  seriestype=[:line :line :line :line :line :scatter], 
  inset_subplots = layout, 
  legend=false, 
  xscale=[:identity :log10], 
  xflip=[false true])

```

But this doesn’t group the various series how I want.

Thanks!

---

<div class="post-metadata">

**Author:** ![NegativeOne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/negativeone/32/51279_2.png) [@NegativeOne](https://discourse.julialang.org/u/NegativeOne)\
**Post date:** [July 5, 2023, 8:25pm UTC](https://discourse.julialang.org/t/how-to-take-two-exisitng-plots-and-inset-one-inside-the-other/101226/2 "2023-07-05T20:25:14Z")

</div>

Got it,

```julia
plot(t, reverse(cohs, dims=2), label=permutedims(labels), lw=[3 2 2 2 2], ls=[:solid :dash :dash :dash :dash], legend=:outerbottom, size=(1500,700), legend_columns=-1)
vline!([K*δt], label=nothing)
scatter!(cutoffs, y, xscale=:log10, xflip=true, color=colors[1], legend=false, inset = bbox(0.65, 0.05, 0.30, 0.35, :top, :left), subplots=2, title="Convergence")
plot!(cutoffs, y, xscale=:log10, xflip=true, color=colors[1], legend=false, subplots=2)
annotate!(10.3, 0.493, text("Memory Cutoff", pointsize=14, family="Computer Modern", rotation=-90))

```
