Excellent.
NB: by editing the last line as follows the legend looks better on my display if using Plots; gr():
plot!(pall, (1:K)', inset = (1, bbox(1.65,0.87,1.0,1.0)), background_color=:transparent,
subplot=D+1,legendfontsize=11,framestyle=:none,label=permutedims(" k=".*string.(1:K).*" "))
and if one wants to remove the border of the inset:
plot!(pall, (1:K)', inset = (1, bbox(1.65,0.87,1.0,1.0)), background_color=:transparent,
subplot=D+1,legendfontsize=11,framestyle=:none,label=permutedims(" k=".*string.(1:K).*" "),
foreground_color_legend = nothing)