Linking subplot x-axes containing dates

sorry but I just feel stupid trying to plot this, tried to use your approach on my data with ZoneDateTime (the original data), converting to DateTime (similar as your example). But my plots just look all the same without decently linked x-axis. In matlab this normally takes me 2 minutes :frowning: .

It is recommended to provide a MWE as per guidelines.

Sure, however I can’t upload attachments here. I’ve added a small dataset here: http://users.telenet.be/goosst/data.jld.
I saved this file in this way:
using JLD save("data.jld","timestamps",timestamps,"pressure",pressure,"timestamps2",timestamps2,"waterdepth",waterdepth)

thanks!

# plotting with zonedatetime
plot_water=plot(Dates.format.(timestamps2,"dd-HH:MM"),waterdepth, xrotation = 60, label="water depth",lw = 3)
plot_pressure=plot(Dates.format.(timestamps,"dd-HH:MM"),pressure,xrotation = 60,label="baro pressure", lw = 3,color=:red)
plot_merged=plot(plot_water,plot_pressure,layout = (2, 1),link=:x,xticks=10)


# using datetime instead of zonedatetime
timestamps_dt=DateTime[];
for i = 1:length(timestamps)
    push!(timestamps_dt,DateTime(timestamps[i]))
end

timestamps2_dt=DateTime[];
for i = 1:length(timestamps2)
    push!(timestamps2_dt,DateTime(timestamps2[i]))
end

plot_water=plot(Dates.format.(timestamps2_dt,"dd-HH:MM"),waterdepth, xrotation = 60, label="water depth",lw = 3)
Plots.plot!(xticks=(timestamps2_dt, Dates.format.(timestamps2_dt,"dd-HH:MM")))


plot_pressure=plot(Dates.format.(timestamps_dt,"dd-HH:MM"),pressure,xrotation = 60,label="baro pressure", lw = 3,color=:red)
Plots.plot!(xticks=(timestamps_dt, Dates.format.(timestamps_dt,"dd-HH:MM")))

plot_merged=plot(plot_water,plot_pressure,layout = (2, 1),link=:x,xticks=10)