# Heatmap with NaNs in GR or GRUtils

**URL:** https://discourse.julialang.org/t/heatmap-with-nans-in-gr-or-grutils/49584
**Category:** General Usage
**Tags:** question, package, plotting
**Created:** [November 4, 2020, 2:03pm UTC](https://discourse.julialang.org/t/heatmap-with-nans-in-gr-or-grutils/49584 "2020-11-04T14:03:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kapple](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kapple/32/218915_2.png) [@kapple](https://discourse.julialang.org/u/kapple)
#### Post date: [November 4, 2020, 2:03pm UTC](https://discourse.julialang.org/t/heatmap-with-nans-in-gr-or-grutils/49584/1 "2020-11-04T14:03:08Z")

</div>

Hi again, I apologize for the proliferation of questions about plotting you may have seen from me here.

I would like to plot a GR or GRUtils heatmap that omits plotting in certain regions.

For example

```julia
julia> using GR

julia> heatmap(1:3., 1:4., [1. 2; 3 NaN; 5 6])
ERROR: InexactError: trunc(Int64, NaN)
Stacktrace:
 [1] trunc at .\float.jl:703 [inlined]
 [2] round(::Type{Int64}, ::Float64) at .\float.jl:367
 [3] plot_data(::Bool) at C:\Users\aaron\.julia\packages\GR\8mv9N\src\jlgr.jl:1305
 [4] plot_data at C:\Users\aaron\.julia\packages\GR\8mv9N\src\jlgr.jl:1074 [inlined]
 [5] heatmap(::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Array{Float64,2}; kv::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\aaron\.julia\packages\GR\8mv9N\src\jlgr.jl:2052
 [6] heatmap at C:\Users\aaron\.julia\packages\GR\8mv9N\src\jlgr.jl:2047 [inlined]
 [7] #heatmap#17 at C:\Users\aaron\.julia\packages\GR\8mv9N\src\GR.jl:3419 [inlined]
 [8] heatmap(::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Array{Float64,2}) at C:\Users\aaron\.julia\packages\GR\8mv9N\src\GR.jl:3419
 [9] top-level scope at REPL[6]:100:

```

It works fine in Plots.jl with GR as the backend… I don’t know how to accomplish what Plots outputs with the GR package alone.

```julia
julia> using Plots
[Info: Precompiling Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80]

julia> heatmap(1.5:2.5, 1.5:3.5, [1. 2; 3 NaN; 5 6])

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/2/4209714e6f2f1b6e9ab44306316c1e13a061f2f2.png)

---

<div class="post-metadata">

### Author: ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)
#### Post date: [November 5, 2020, 2:52pm UTC](https://discourse.julialang.org/t/heatmap-with-nans-in-gr-or-grutils/49584/2 "2020-11-05T14:52:49Z")

</div>

For GR this should be fixed in [a8402dd0](https://iffgit.fz-juelich.de/Scientific-IT-Systems/gr.jl/-/commit/a8402dd07614219a6f30f27da4acfa768bf817d2)
