log2
and symlog
¶from lets_plot import *
LetsPlot.setup_html()
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})
df = get_data(10)
df.tail()
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 |
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)