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

[BUG] Distorted log-scale heatmap and 2d-hist plots with GR #3643

Closed
oschulz opened this issue Jul 15, 2021 · 4 comments
Closed

[BUG] Distorted log-scale heatmap and 2d-hist plots with GR #3643

oschulz opened this issue Jul 15, 2021 · 4 comments
Labels

Comments

@oschulz
Copy link
Contributor

oschulz commented Jul 15, 2021

With the GR backend (Plots v1.19.1), heatmaps (and so 2D histograms too) are distorted if the axis range spans several decades:

using Plots; gr()

z = rand(Bool, 50, 50)
plot(
    heatmap(z),
    heatmap(10 .^ range(-2, 0, length=50), 10 .^ range-2, 0, length=50), z, scale = :log10),
    heatmap(10 .^ range(-5, 0, length=50), 10 .^ range(-5, 0, length=50), z, scale = :log10),
    heatmap(10 .^ range(0, 5, length=50), 10 .^ range(-5, 0, length=50), z, scale = :log10)
)

results in this plot:

log-heatmaps-gr

all four sub-plots should look the same (except for the axis scales), but the lower two (with axes spanning 5 decades) are very distorted.

With pyplot

pyplot()

plot(
    heatmap(z),
    heatmap(10 .^ range(-2, 0, length=50), 10 .^ range(-2, 0, length=50), z, scale = :log10),
    heatmap(10 .^ range(-5, 0, length=50), 10 .^ range(-5, 0, length=50), z, scale = :log10),
    heatmap(10 .^ range(0, 5, length=50), 10 .^ range(-5, 0, length=50), z, scale = :log10)
)

everything looks fine:

log-heatmaps-pyplot

I'm not sure if this is a Plots or GR bug (CC @jheinen ).

@oschulz oschulz added the bug label Jul 15, 2021
@t-bltg
Copy link
Member

t-bltg commented Jul 15, 2021

Reproducible reduced case:

using Random, Plots

main() = begin
  Random.seed!(1234)
  m, n = 4, 8
  z = rand(Bool, m, n)
  plot(
    heatmap((10.).^range(-2, 0, length=n), (10.).^range(-2, 0, length=m), z, scale=:log10),
    heatmap((10.).^range(-5, 0, length=n), (10.).^range(-5, 0, length=m), z, scale=:log10),
    layout=(2, 1)
  )
  png("hm-$(backend())")
  return
end

gr(); main()
pyplot(); main()

Pyplot

hm-Plots PyPlotBackend()

GR

hm-Plots GRBackend()

@jheinen
Copy link
Member

jheinen commented Nov 19, 2021

The problem is fixed in the development branch of GR (see this commit)- a new release will be tagged soon.
Screen Shot 2021-11-19 at 10 07 37
Screen Shot 2021-11-19 at 10 11 38

@oschulz
Copy link
Contributor Author

oschulz commented Nov 19, 2021

Thanks a lot @jheinen !

@t-bltg
Copy link
Member

t-bltg commented Nov 20, 2022

This issue seems fixed.

@t-bltg t-bltg closed this as completed Nov 20, 2022
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

4 participants