python - Plain notation in seaborn plots -


i started using seaborn , use pyplot.plot function, , whenever use log scales axis ticks presented 10 power. before using seaborn, line

    ax.xaxis.set_major_formatter(formatstrformatter('%.0f')) 

was fixing problem, seaborn not. ideas how can have plain notation on axes?

below example of code. x axis of form: 0.1, 1, 10 , 100 .. , not now.

import matplotlib.pyplot plt import seaborn sns sns.set_style('ticks',  {'font.family': 'sans-serif'}) sns.set_context("paper", font_scale=1.3) plt.rc('text', usetex=true)   x_lim=[0.1,100] y_lim=[1.2001, 2.2001] f = plt.figure() plt.xscale('log') plt.ylim(y_lim) plt.xlim(x_lim) plt.hlines(1.5, *x_lim, color='grey') plt.show() 

enter image description here

the key thing placement of formatter line. has after ax.set_xscale('log').

rather using %.0f removes numbers after decimal place (leaving 0 rather 0.1), use %g, round 1 significant figure. i've extended example use subplot format can set:

import matplotlib.pyplot plt import matplotlib.ticker tck import seaborn sns  sns.set_style('ticks',  {'font.family': 'sans-serif'}) sns.set_context("paper", font_scale=1.3) plt.rc('text', usetex=true)   x_lim=[0.1,100] y_lim=[1.2001, 2.2001]  f = plt.figure() ax = f.add_subplot(plt.subplot(1, 1, 1)) ax.set_xscale('log') ax.set_ylim(y_lim) ax.set_xlim(x_lim) ax.hlines(1.5, *x_lim, color='grey') ax.xaxis.set_major_formatter(tck.formatstrformatter('%g'))  plt.show() 

this produces image:

enter image description here


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -