Plots, heatmap and xlim

Dear all,

We just came across a weird behaviour when using (inapproriately) xlim.
In the MWE below, x and y axis are arrays/ranges of very large numbers (say a map of ~1000 km width/height given in unit meters, so order 1e6 ) and xlim values are (by error) provided in unit km (so order 1e3).
The execution of heatmap command stalls and ends up using memory until crash (commented line). This behaviour happened on windows and macs. I realise that it is related to an incorrect combination of dimensions but I still would not expect this to trigger a crash (I would rather expect a massive zoom on a portion of the map). Does anyone know why this triggers a crash?

edit: crash was observed with gr

Thanks!

using Plots
x = LinRange(0., 1.0, 100) .*1e6
y = LinRange(0., 1.2, 100) .*1e6
f = rand(length(x), length(y))
heatmap(x, y, f') # this one works
# heatmap(x, y, f', xlim=(0,1000.)) # this one stalls and ends up crashing

Both heatmaps run fine for me on Linux and gr backend.

julia> versioninfo()
Julia Version 1.8.3
Commit 0434deb161e (2022-11-14 20:14 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 6 × Intel(R) Core(TM) i7-3960X CPU @ 3.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, sandybridge)
  Threads: 1 on 6 virtual cores
Environment:
  JULIA_ERROR_COLOR = red
  JULIA_WARN_COLOR = red
  JULIA_INFO_COLOR = red

(@v1.8) pkg> status Plots
Status `~/.julia/environments/v1.8/Project.toml`
⌃ [91a5bcdd] Plots v1.36.5

EDIT: They still work fine after Pkg.update() bringing Plots to v1.38.6.

thanks for having checked!
I will also try on a linux machine and with similar versions for curiosity…

1 Like

I can confirm this issue still exists (and seems likely related to this open issue)

Im my case, I encountered this when using xlim and ylim to zoom into a small region of a large heatmap.

Im running on Julia 1.11.5 and linux.

Julia Version 1.11.5
Commit 760b2e5b739 (2025-04-14 06:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 112 × Intel(R) Xeon(R) Gold 6348 CPU @ 2.60GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, icelake-server)
Threads: 32 default, 0 interactive, 16 GC (on 112 virtual cores)
Environment:
  JULIA_PKG_SERVER = http://julia.llan.ll.mit.edu/julia
  JULIA_NUM_THREADS = 32
  JULIA_EDITOR = code
  JULIA_VSCODE_REPL = 1

FWIW, I am using the Julia and remotessh vscode plugins. Also of note, the heatmap call itself returns quickly, and the crash occurs on rendering:

using Plots
x = LinRange(0., 1.0, 100) .*1e6
y = LinRange(0., 1.2, 100) .*1e6
f = rand(length(x), length(y))
heatmap(x, y, f') # this one works
heatmap(x, y, f', xlim=(0,1000.)); # this line runs fine is plot if not displayed
display(plot!())   # crash occurs here

Happy to provide more info or do more testing if needed…