Plot ticks at both top and bottom axis

This is an old post but something I stumbled with today and took me a bit to find a fix. Copying here something I put on an associated issue in Plots.jl github page (https://github.com/JuliaPlots/Plots.jl/issues/2218), just in case it can help someone.

Not a proper fix, but here is a workaround I found. I just create a twin axis in each direction, match the x and y boundaries and remove labels using a copy_ticks function.

function twiny(sp::Plots.Subplot)
    sp[:top_margin] = max(sp[:top_margin], 30Plots.px)
    plot!(sp.plt, inset = (sp[:subplot_index], bbox(0,0,1,1)))
    twinsp = sp.plt.subplots[end]
    twinsp[:xaxis][:mirror] = true
    twinsp[:background_color_inside] = RGBA{Float64}(0,0,0,0)
    Plots.link_axes!(sp[:yaxis], twinsp[:yaxis])
    twinsp
end
twiny(plt::Plots.Plot = current()) = twiny(plt[1])

function copy_ticks(sp::Plots.Subplot)
    ptx = twinx(sp)
    plot!(ptx,xlims=xlims(plt),ylims=ylims(plt),xformatter=_->"",yformatter=_->"")
    pty = twiny(sp)
    plot!(pty,xlims=xlims(plt),ylims=ylims(plt),xformatter=_->"",yformatter=_->"")
end
copy_ticks(plt::Plots.Plot = current()) = copy_ticks(plt[1])

plt = plot(sin)
copy_ticks()
display(plt)
savefig("sine.png")

This was built with code from two sources:

sine