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

Heatmap and contour bugs #674

Closed
briochemc opened this issue Aug 3, 2020 · 1 comment
Closed

Heatmap and contour bugs #674

briochemc opened this issue Aug 3, 2020 · 1 comment

Comments

@briochemc
Copy link
Contributor

I raised this issue on Slack but since it looks like there is a bug somewhere (actually possibly multiple bugs), it's probably better to start an issue here. MWE:

x = tan.(atan(-3):0.1:atan(3))
y = collect(-2.5:0.1:2.5)
peaks(x,y) = 3*(1-x)^2 * exp(-(x^2) - (y+1)^2) - 10*(x/5 - x^3 - y^5) * exp(-x^2-y^2) - 1/3*exp(-(x+1)^2 - y^2)
z = [peaks(x,y) for y in y, x in x]

using AbstractPlotting
using AbstractPlotting.MakieLayout
using GLMaki
scene, layout = layoutscene()
display(scene)
ax = layout[1,1] = LAxis(scene)
heatmap!(ax,x,y,z)
contour!(ax,x,y,z,color=:black)

using Plots
Plots.heatmap(y,x,z')
Plots.contour!(y,x,z',color=:black)

which spits out a heatmap with overlaid contours of the peaks function, with an irregularly spaced x. Plots (GR) output on the left and Makie output on the right:

Screen Shot 2020-08-03 at 1 53 28 pm

I see a number of problems with Makie:

  • The contours and heatmap are not aligned.
  • The contours are jumping around
  • Both the heatmap and contours don't handle the irregular x

BTW, I'm not saying Plots is perfect (e.g., it's not showing the "top" most layer, which you can see because the y axis does not go above ≈2.3 despite there being a y=2.5 value), but I think Makie's output is really far off here.

I'm not sure how I can help, please let me know! 🙂 (I would really like to use MakieLayout for some publication-quality plots that I need very soon and use heatmaps and contours)

@briochemc
Copy link
Contributor Author

briochemc commented Aug 4, 2020

So it turns out that for regularly spaced grids, swapping the orientation of z does the trick (thanks Staffan Hellström on Slack). MWE [EDITED (copied the wrong snippet earlier)]:

x = -3:0.1:3
y = -2.5:0.1:2.5
peaks(x,y) = 3*(1-x)^2 * exp(-(x^2) - (y+1)^2) - 10*(x/5 - x^3 - y^5) * exp(-x^2-y^2) - 1/3*exp(-(x+1)^2 - y^2)
z = [peaks(x,y) for x in x, y in y]

using AbstractPlotting
using AbstractPlotting.MakieLayout
using GLMakie
scene, layout = layoutscene()
display(scene)
ax = layout[1,1] = LAxis(scene)
heatmap!(ax,x,y,z)
contour!(ax,x,y,z,color=:black)

gives

Screen Shot 2020-08-04 at 11 57 25 am

I'll open a separate issue for the irregularly spaced grids.

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

No branches or pull requests

2 participants