matplotlibdata-visualizationseaborn

Seaborn: how to make a Log base 2 axis in a small multiples plot?


I'm doing a small multiples plot with seaborn using relplot:

g = sns.relplot(data=df,
                kind='scatter',
                col='mycol', row='arow',
                x='a', y='b', 
                hue='c',
                legend=False,
                alpha=.5)

I can easily tranform the axis for a log scale in base 10:

g.set(xscale="log")
g.set(yscale="log")

If I were ploting a simple plot with matplotlib I'd be able to use a log scale in base 2:

ax.set_xscale('log', basex=2)
ax.set_yscale('log', basey=2)

But how do I make a Log2 plot in Seaborn?


Solution

  • Just discovered how to do it using a global function:

    plt.xscale('log', basex=2)
    plt.yscale('log', basey=2)