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

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

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

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

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

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

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!

Got it,

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))
1 Like