Plots.jl bug with twinx and link

I was doing some plotting and wondering why my x-axis behaved strangely when using link=:x.

First the code

	using Plots
	x1 = 0:0.1:π
	x2 = 0:0.1:3;
	p1 = plot(x1,sin.(x1))
	p1 = plot!(twinx(), x2,cos.(x2))
	p2 = plot(x2,sin.(x2))
	p2 = plot!(twinx(), x2, cos.(x2))
	p3 = plot(p1, p2, layout=(2,1))
	p4 = plot(p1, p2, layout=(2,1), link=:x)
	savefig(p3, p3.png)
	savefig(p4, p4.png)

p3 gives the expected plot.
p4 lower plot gives the expected line for x1 but the line for x2 goes to pi rather than to 3.

1 Like