Link axis not working in Plots for marginal density

I’m trying to put in marginal density plots above and to the right of x,y scatter data.

I have tried the ‘link’ in both the :x, :y, and :both directions but as you can see the top figure does not match the axis of the bottom figure.

using Plots, StatsPlots, KernelDensity, DataFrames, Images,Plots.PlotMeasures
topdensity = @df finalDeckLocation density(:POSYI,group = :subject,xlim=[left2center,center2right])
sidedensity = plot(ky.density,ky.x; 	ylim=[(center2top-top2bottom),center2top])
Plots.plot([left2center,center2right],
	[(center2top-top2bottom),
	center2top],reverse(img, dims = 1),
 	yflip = false,
  	aspect_ratio = 1,
  	xlim=[left2center,center2right],
  	ylim=[(center2top-top2bottom),center2top],
  	left_margin = [20mm 0mm],
   	bottom_margin = 10mm);
deckfinalposplot = @df @subset(finalDeckLocation, :subject .<=3) scatter!(
	:POSYI,
	(:SHIPXI .-:POSXI.-174).*-1,
	xlim=[left2center,center2right],
	ylim=[(center2top-top2bottom),center2top],
	group = :iteration,
	markercolor = :subject,
	markersize = 2,
	alpha = 0.5,
	legend = :none,
	dpi=300)

layout = @layout [
    topdensity             _
    deckfinalposplot{0.8w, 0.8h}  sidedensity
]

plot(topdensity,  deckfinalposplot, sidedensity; layout, link = :x, dpi = 300)