Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GR: heatmap and line plot with linked axes not aligned correctly #1912

Open
yha opened this issue Feb 5, 2019 · 3 comments
Open

GR: heatmap and line plot with linked axes not aligned correctly #1912

yha opened this issue Feb 5, 2019 · 3 comments
Labels

Comments

@yha
Copy link
Member

yha commented Feb 5, 2019

plot( heatmap(1:10,1:10, (x,y)->x/(x+y)),
      plot(1:10,rand(10)),
      layout=(2,1), link=:x )

On GR:
image

The line plot did cause the heatmap x axis to widen, but the x axes are not aligned.

In PyPlot, the same example looks fine.
In PlotlyJS the alignment is ok, and it helpfully hides the axes on the top plot (could be a nice feature in other backends too). But there's a mysterious line near the top of the colorbar (I guess it's part of the legend, so it's probably related to #694)
image

@mkborregaard
Copy link
Member

Yes I think this is due to GR's behaviour with colour bars, where it plots the color bar as part of the plot. So the axes are correctly lined up, but then they get compressed by GR when it adds the color bar. I think this to fix this we'd need to take into account how much the color bar displaces the image, then displace the bottom images by that amount as well. @jheinen do you know how much that is?

@jheinen
Copy link
Member

jheinen commented Feb 5, 2019

I think, it's 10%:

const gr_colorbar_ratio = 0.1

@daschw daschw added the GR label Apr 2, 2019
@LRBaalmann
Copy link

It would be nice if this could be fixed; it still is a quite annoying issue. In GR, the code

using Plots
p1 = plot(1:10, rand(10))
p2 = plot(4:14, rand(11))
p3 = heatmap(2:12, 2:12, rand(Float64, (10,10)))
l = @layout [a{.3h};b{.3h};c{.4h}]
p = plot(p1,p2,p3, layout=l, link=:x)

produces the attached image
plots_err_xalign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants