# Link axes in Plots.jl

**URL:** <https://discourse.julialang.org/t/link-axes-in-plots-jl/40426>\
**Category:** Visualization\
**Tags:** plots\
**Created:** [May 29, 2020, 4:05pm UTC](https://discourse.julialang.org/t/link-axes-in-plots-jl/40426 "2020-05-29T16:05:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Post date:** [May 29, 2020, 4:05pm UTC](https://discourse.julialang.org/t/link-axes-in-plots-jl/40426/1 "2020-05-29T16:05:42Z")

</div>

I want to plot the projections of a 2d map on the right and below the 2d plot, but if I show the colorbar the axis are not aligned anymore.

How can I align the axes?  
Is there a way to place the colorbar in the bottom right corner to get axes aligned ?

Here is the sample code

```julia
using Plots
x = rand(20)
y = rand(20).+10
z = rand(20).*10
l = @layout [a{0.5w,0.5h} b;c _]
plot(layout=l, grid=false,legend=false,link=:both)
plot!(x,y,marker_z=z,seriestype=:scatter,marker=7,subplot=1,colorbar=true)
plot!(z,y,seriestype=:scatter,marker=7,subplot=2)
plot!(x,z,seriestype=:scatter,marker=7,subplot=3)

```

 ![Capture](https://global.discourse-cdn.com/julialang/original/2X/5/5c114d552093e22b49e4347aca3f400eb02a9502.png)

---

<div class="post-metadata">

**Author:** ![josephmarturano](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@josephmarturano](https://discourse.julialang.org/u/josephmarturano)\
**Post date:** [May 29, 2020, 6:43pm UTC](https://discourse.julialang.org/t/link-axes-in-plots-jl/40426/2 "2020-05-29T18:43:05Z")

</div>

Could you use the `pyplot()` backend for your application? If so, it appears the x-axes are aligned:

```julia
using Plots
pyplot() #note the pyplot backend
x = rand(20)
y = rand(20).+10
z = rand(20).*10
l = @layout [a{0.5w,0.5h} b;c _]
pyplotoutput = plot(layout=l, grid=false,legend=false,link=:both)
plot!(x,y,marker_z=z,seriestype=:scatter,marker=7,subplot=1,colorbar=true)
plot!(z,y,seriestype=:scatter,marker=7,subplot=2)
plot!(x,z,seriestype=:scatter,marker=7,subplot=3)

savefig(pyplotoutput, "pyplotoutput.png")

```

which produces the following:

![pyplotoutput](https://global.discourse-cdn.com/julialang/original/3X/1/2/121ae005fa4e85360b8676e8e63bd0850e195b82.png)

---

<div class="post-metadata">

**Author:** ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Post date:** [May 29, 2020, 8:46pm UTC](https://discourse.julialang.org/t/link-axes-in-plots-jl/40426/3 "2020-05-29T20:46:55Z")

</div>

So it seems this is handled by the backend.  
@jheinen is it possible to do it with gr as well?
