# Makie: axis limits with Inf

**URL:** <https://discourse.julialang.org/t/makie-axis-limits-with-inf/85784>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [August 15, 2022, 3:45pm UTC](https://discourse.julialang.org/t/makie-axis-limits-with-inf/85784 "2022-08-15T15:45:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tt1234567](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tt1234567](https://discourse.julialang.org/u/tt1234567)\
**Post date:** [August 15, 2022, 3:45pm UTC](https://discourse.julialang.org/t/makie-axis-limits-with-inf/85784/1 "2022-08-15T15:45:06Z")

</div>

GLMakie doesn’t seem to adjust axis limits automatically if the data contains an `Inf`. E,g.

```julia
using GLMakie
lines(1:6,[-1, -2, 3, -Inf, -10, -11])

```

gives

 ![inf](https://global.discourse-cdn.com/julialang/original/3X/a/3/a31577f3b81051240e9f26ea42b3aa3d3ccd5047.png)  
You have to use `xlims!()` and `ylims()` to see all the data. It seems ok with NaN:

```julia
lines(1:6,[-1, -2, 3, NaN, -10, -11])

```

gives

 ![nan](https://global.discourse-cdn.com/julialang/original/3X/6/3/63659bc2462601b3f515d3b3c063c7345b49d7d5.png)  
I’m using Julia 1.7.3, GLMakie v0.6.13 on Windows 10.

---

<div class="post-metadata">

**Author:** ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Post date:** [August 15, 2022, 4:04pm UTC](https://discourse.julialang.org/t/makie-axis-limits-with-inf/85784/2 "2022-08-15T16:04:48Z")

</div>

They will probably appreciate it if you have the chance to report this as a bug on their issue tracker on github. They would appreciate it even more if you provide a pull request with a fix 😃

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [August 15, 2022, 4:15pm UTC](https://discourse.julialang.org/t/makie-axis-limits-with-inf/85784/3 "2022-08-15T16:15:51Z")

</div>

Not sure what exactly happens there but I always wonder if Inf should be allowed at all in a plot. Rendering a NaN in with a gap seems reasonable to me, but shouldn’t a point to Inf be a vertical line instead of nothing if we show it at all? Because it’s visually ill defined I would probably rather error than silently do weird behavior like this

---

<div class="post-metadata">

**Author:** ![tt1234567](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tt1234567](https://discourse.julialang.org/u/tt1234567)\
**Post date:** [August 15, 2022, 4:25pm UTC](https://discourse.julialang.org/t/makie-axis-limits-with-inf/85784/4 "2022-08-15T16:25:39Z")

</div>

I’m not really sure what it ought to do. I often plot things like `10*log10.(x)` and it’s easier not to have to check for zeros first but maybe that’s just being lazy. I used to use Matlab quite a lot for that sort of thing but I can’t remember how it behaves.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [August 15, 2022, 5:10pm UTC](https://discourse.julialang.org/t/makie-axis-limits-with-inf/85784/5 "2022-08-15T17:10:34Z")

</div>

yeah it’s difficult, you cannot really visualize infinities so if you want to show _something_ then it has to be “hacky” to some degree I think

---

<div class="post-metadata">

**Author:** ![MA\_Laforge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ma_laforge/32/385_2.png) [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Post date:** [August 25, 2022, 3:32am UTC](https://discourse.julialang.org/t/makie-axis-limits-with-inf/85784/6 "2022-08-25T03:32:02Z")

</div>

> [@jules](#):
>
> but shouldn’t a point to Inf be a vertical line instead of nothing if we show it at all?

👍. Yes. I think this would be correct thing to do. Simply draw a line to the edge (or beyond) the plot clipping region. Hopefully the extra “if” statements won’t slow down the plotting algorithm in a significant way.

### Similarly:

- `(x,y) = (inf, FINITEVAL)` should also be drawn as a horizontal line to the edge of the plot.

### Comment on @tt1234567’s example

The `inf` → `NaN` substitution appears to hilight a 2nd, more trivial issue:

- `inf` values should be ignored when computing the _ **x/y limits** _ of the plot.
- It appears that Makie gives up as soon as an infinite value is detected (keeping with its default extents of: `(xmin,xmax)=(ymin,ymax)=(0,10)`)

> [@jules](#):
>
> Because it’s visually ill defined I would probably rather error than silently do weird behavior like this

I disagree: I don’t think it is ill defined (at least not visually).

But I would agree there are **practical** issues with such an implementation (ex: more complexity; vertical lines should be re-drawn as the user pans/zooms on the plot).

> [@tt1234567](#):
>
> I often plot things like `10*log10.(x)` and it’s easier not to have to check for zeros first but maybe that’s just being lazy.

Agreed. Computing gain in dB (much as you describe) occurs quite often when processing data from circuit simulators at zero gain points. It is unpleasant to constantly add sanity checks/validation functions before plotting.

I also encounter similar issues when plotting results obtained from calculations of incomplete datasets (or when there are bugs with the calculations themselves 🤦‍♂️)

I find that having a way of “showing” infinite tendencies on a plot is often useful (even if you can’t show infinity itself).
