# Plot range not working as excpected

**URL:** https://discourse.julialang.org/t/plot-range-not-working-as-excpected/38978
**Category:** General Usage
**Created:** [May 7, 2020, 6:11pm UTC](https://discourse.julialang.org/t/plot-range-not-working-as-excpected/38978 "2020-05-07T18:11:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Eris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eris/32/8438_2.png) [@Eris](https://discourse.julialang.org/u/Eris)
#### Post date: [May 7, 2020, 6:11pm UTC](https://discourse.julialang.org/t/plot-range-not-working-as-excpected/38978/1 "2020-05-07T18:11:53Z")

</div>

I’m plotting a divergent function and I want the graph to reflect a certain value of y. For example the function y=-log(1-x) approaches infinity at x=1 however the output shows that it stops before y=10

> using Plots  
> f(x)=-log(1-x)  
> plot(f, 0,1,ylims=(0,20))

![Test](https://global.discourse-cdn.com/julialang/original/3X/0/f/0fb6e5c46f032e7c95121b3f3d97a9e93ff6fd17.png)

---

<div class="post-metadata">

### Author: ![mlanghinrichs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlanghinrichs/32/50371_2.png) [@mlanghinrichs](https://discourse.julialang.org/u/mlanghinrichs)
#### Post date: [May 7, 2020, 6:44pm UTC](https://discourse.julialang.org/t/plot-range-not-working-as-excpected/38978/2 "2020-05-07T18:44:14Z")

</div>

I think Plots does not plot `Inf` values, so that f(x) at x=1 is not actually plotted. (That `Inf`’s are not plotted can be seen by executing `plot([0, 1], [1, Inf])` for example).

Not a perfect solution but as a workaround, you could replace `Inf`’s with a high number that is far outside your plotting range:

```julia
using Plots

f(x) = -log(1.0 - x)

x = range(0.0, 1.0, length=10000)
y = f.(x)
y[y .> 1000.0] .= 1000.0 # introduce some cutoff

plot(x, y, ylims=(0.0, 20.0), xlims=(0.0, 1.1))

```

This will plot:  
 ![test](https://global.discourse-cdn.com/julialang/original/3X/d/1/d18b591eb46691fa2d8f5260c1f1afd5245bcb6e.png)

Maybe someone else has a better idea though…
