# Plots.jl bug with twinx and link

**URL:** <https://discourse.julialang.org/t/plots-jl-bug-with-twinx-and-link/125809>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [February 11, 2025, 9:02pm UTC](https://discourse.julialang.org/t/plots-jl-bug-with-twinx-and-link/125809 "2025-02-11T21:02:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)\
**Post date:** [February 11, 2025, 9:02pm UTC](https://discourse.julialang.org/t/plots-jl-bug-with-twinx-and-link/125809/1 "2025-02-11T21:02:04Z")

</div>

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

First the code

```julia
	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.

 ![p3](https://global.discourse-cdn.com/julialang/original/3X/4/6/46e10e61fd538d4c9e344da039ef559e4dd5eed4.png)

 ![p3](https://global.discourse-cdn.com/julialang/original/3X/5/a/5abc1af836f7cc26cac5655c86ba429cc6d65c52.png)
