Plots.jl using layout with shared xaxis

Hello. I’m in a bit trouble with Plots.jl uisng layout. May be this is a basic question, but I can’t find the solution in the document. I want to make the multiple plot with several panels sharing the same x axis. MWE is below

using Plots

x = range(0, step = 0.01, stop = 2pi)
y1 = sin.(x)
y2 = cos.(x)

plt1 = plot(x, y1)
plt2 = plot(x, y2)
plot(plt1, plt2, layout = (2, 1), framestyle=:box)

The results is follows.
I want to make it shared axis, meaning that to remove x-label and numbers in the upper panel, but the ticks intact. How can I do this?

In that example that would be

plt1 = plot(x, y1, xlabel="", xticks=(1:6, fill("", 6)))

Thanks! It worked!

Fyi, to get rid of the xtick labels you could also use xformatter keyword:

plt1 = plot(x, y1, xformatter=_->"")

PS: if you also would like to reduce the space between the subplots you need to use Measures.

1 Like