# How to avoid zeros while using log on axis?

**URL:** https://discourse.julialang.org/t/how-to-avoid-zeros-while-using-log-on-axis/101310
**Category:** New to Julia
**Tags:** question, plotting
**Created:** [July 7, 2023, 12:18pm UTC](https://discourse.julialang.org/t/how-to-avoid-zeros-while-using-log-on-axis/101310 "2023-07-07T12:18:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Sahil\_Khan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sahil_khan/32/47573_2.png) [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)
#### Post date: [July 7, 2023, 12:18pm UTC](https://discourse.julialang.org/t/how-to-avoid-zeros-while-using-log-on-axis/101310/1 "2023-07-07T12:18:16Z")

</div>

Is there way to avoid zero in data go -Inf and still have log axis during plotting?

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [July 7, 2023, 1:03pm UTC](https://discourse.julialang.org/t/how-to-avoid-zeros-while-using-log-on-axis/101310/2 "2023-07-07T13:03:48Z")

</div>

> <https://github.com/MakieOrg/Makie.jl/pull/3004>
>
> Fix #3000 
> 
> This implements what's suggested on Slack, namely, detect if trans…formation is one of the dangerous logs (example of non-dangerous log is \`Makie.pseudolog10\`), if so, use the minimal non zero value divided by 2 as the "bottom" to avoid illegal transformation \`0 -\> -Inf\` when applying the log.
> 
> Some examples that used to error but now works:
> 
> \`\`\`julia
> using CairoMakie
> 
> a = "/tmp/jl\_k9M7ELsL2h.png"
> 
> save(a, hist(randn(10^6); axis=(; yscale=log10)))
> 
> save(a, hist(randn(10^6); axis=(; yscale=log2)))
> 
> save(a, hist(filter!(x-\> x\<0 || x \> 1.5, randn(10^6)); axis=(; yscale=log10)))
> \`\`\`
> 
> !\[image\](https://github.com/MakieOrg/Makie.jl/assets/5306213/f0d5b033-22a5-40ee-bb9b-83d5eebab175)
> 
> !\[image\](https://github.com/MakieOrg/Makie.jl/assets/5306213/67b3cd16-aa4b-4193-a967-7327b3c26886)
> !\[image\](https://github.com/MakieOrg/Makie.jl/assets/5306213/0019c19b-7ada-41e0-9919-68ce32f7c43b)
