1

I want to align the x-axises from a heatmap and an areaplot with Plots.jl:

enter image description here

But the thing is that the colorbar disaligns the axes. Any ideas to actually achieve this or any work around that could be useful?

My main plot function looks like this:

pyplot()
p = plot(p1,p2,
    size=(1200,500),
    dpi = 300,
    right_margin=20px,
    top_margin=10px,
    layout = @layout[a{0.75h,1w}; b{0.25h,1w};])

Edit:

A work around is to plot the colorbar on top of the heatmap but that is not very satisfying.

DisabledWhale
  • 771
  • 1
  • 7
  • 15
  • 2
    Have you tried `link=:x`? Maybe [this issue](https://github.com/JuliaPlots/Plots.jl/issues/1912) is helpful too? – Benoit Pasquier Feb 02 '21 at 00:33
  • I had not tried the `link` argument but it does not work. I have followed the tutorial: http://docs.juliaplots.org/latest/generated/pyplot/#pyplot-ref44. Thanks for bringing the issue to my mind. I will try to engage in that! – DisabledWhale Feb 02 '21 at 11:31

1 Answers1

1

A workaround that works for me is to include an empty small plot just below the colorbar:

> p_empty = plot([NaN], axis=false, grid=false, background_color=:transparent);
> ll = @layout [a{0.75h}; b{0.955w} c]
> p = plot(p1, p2, p_empty, layout=ll)
Dharman
  • 30,962
  • 25
  • 85
  • 135
pablosaa
  • 108
  • 1
  • 5