# Plots, heatmap and xlim

**URL:** <https://discourse.julialang.org/t/plots-heatmap-and-xlim/95448>\
**Category:** Visualization\
**Tags:** bug, plots\
**Created:** [March 2, 2023, 2:26pm UTC](https://discourse.julialang.org/t/plots-heatmap-and-xlim/95448 "2023-03-02T14:26:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gravlax](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Post date:** [March 2, 2023, 2:26pm UTC](https://discourse.julialang.org/t/plots-heatmap-and-xlim/95448/1 "2023-03-02T14:26:03Z")

</div>

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!

```julia
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

```

---

<div class="post-metadata">

**Author:** ![John\_Gibson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_gibson/32/5321_2.png) [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)\
**Post date:** [March 2, 2023, 4:41pm UTC](https://discourse.julialang.org/t/plots-heatmap-and-xlim/95448/3 "2023-03-02T16:41:44Z")

</div>

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

```julia
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.

---

<div class="post-metadata">

**Author:** ![Gravlax](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Post date:** [March 2, 2023, 8:41pm UTC](https://discourse.julialang.org/t/plots-heatmap-and-xlim/95448/4 "2023-03-02T20:41:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jpdoane](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jpdoane](https://discourse.julialang.org/u/jpdoane)\
**Post date:** [July 15, 2025, 4:46pm UTC](https://discourse.julialang.org/t/plots-heatmap-and-xlim/95448/5 "2025-07-15T16:46:18Z")

</div>

I can confirm this issue still exists (and seems likely related to [this open issue](https://github.com/JuliaPlots/Plots.jl/issues/3417))

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
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:

```julia
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…
