New Scale Transformations: log2 and symlog

In [1]:
from lets_plot import *
In [2]:
LetsPlot.setup_html()
In [3]:
def get_data(n):
    import numpy as np
    import pandas as pd

    x = np.arange(-n, n + 1).astype(float)
    y = np.where(x >= 0, np.where(x == 0, x, np.power(np.e, x)), -np.power(np.e, -x))

    return pd.DataFrame({'x': x, 'y': y})
In [4]:
df = get_data(10)
df.tail()
Out[4]:
x y
16 6.0 403.428793
17 7.0 1096.633158
18 8.0 2980.957987
19 9.0 8103.083928
20 10.0 22026.465795
In [5]:
p = ggplot(df, aes('x', 'y')) + geom_point()

gggrid([
    p + ggtitle("Default"),
    p + scale_y_continuous(trans='symlog') + ggtitle("trans='symlog'"),
    p + scale_y_continuous(trans='log10') + ggtitle("trans='log10'"),
    p + scale_y_continuous(trans='log2') + ggtitle("trans='log2'"),
], ncol=2)
Out[5]: