# Recipe for symlog scale

**URL:** https://discourse.julialang.org/t/recipe-for-symlog-scale/26455
**Category:** New to Julia
**Tags:** question, plotting
**Created:** [July 17, 2019, 8:03am UTC](https://discourse.julialang.org/t/recipe-for-symlog-scale/26455 "2019-07-17T08:03:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)
#### Post date: [July 17, 2019, 8:03am UTC](https://discourse.julialang.org/t/recipe-for-symlog-scale/26455/1 "2019-07-17T08:03:02Z")

</div>

I want to plot x/y data (lines) using a symlog scale. I wrote 2 functions to convert the data points and one to adapt the ticks. So basically I can do:

```julia
using Plots
x = collect(-10:0.01:10)
y = collect(-10:0.01:10)
plot(x, symlog(y,-3.0), yformatter=x->symlogformatter(x, -3.0))

```

![demo](https://global.discourse-cdn.com/julialang/original/3X/a/5/a522db6e5d1d1829e042e0aea4e7ca6487450a98.png)

How can I extend the plot function to use the argument `yscale = SymLog(-3)` ?

The two crude functions look like this:

```julia
function symlog(x,n=-3) 
    result = zeros(size(x,1))
    for i in 1:size(x,1)
        result[i] = sign(x[i])*(log10(1+abs(x[i])/(10^n))) 
    end
    result
end

function symlogformatter(x,n)
    if sign(x) == 0
        "10^$(n)"
    else
        s = sign(x)==1 ? "+" : "-"
        nexp = sign(x)*(abs(x) + n)
        if sign(x) == -1
            nexp = -nexp
        end
        s*"10^$(nexp)"
    end
end

```
