Note

Go to the endto download the full example code.

Scales overview#

Illustrate the scale transformations applied to axes, e.g. log, symlog, logit.

Seematplotlib.scale for a full list of built-in scales, andCustom scale for how to create your own scale.

importmatplotlib.pyplotaspltimportnumpyasnpx=np.arange(400)y=np.linspace(0.002,1,400)fig,axs=plt.subplots(3,2,figsize=(6,8),layout='constrained')axs[0,0].plot(x,y)axs[0,0].set_yscale('linear')axs[0,0].set_title('linear')axs[0,0].grid(True)axs[0,1].plot(x,y)axs[0,1].set_yscale('log')axs[0,1].set_title('log')axs[0,1].grid(True)axs[1,0].plot(x,y-y.mean())axs[1,0].set_yscale('symlog',linthresh=0.02)axs[1,0].set_title('symlog')axs[1,0].grid(True)axs[1,1].plot(x,y)axs[1,1].set_yscale('logit')axs[1,1].set_title('logit')axs[1,1].grid(True)axs[2,0].plot(x,y-y.mean())axs[2,0].set_yscale('asinh',linear_width=0.01)axs[2,0].set_title('asinh')axs[2,0].grid(True)# Function x**(1/2)defforward(x):returnx**(1/2)definverse(x):returnx**2axs[2,1].plot(x,y)axs[2,1].set_yscale('function',functions=(forward,inverse))axs[2,1].set_title('function: $x^{1/2}$')axs[2,1].grid(True)axs[2,1].set_yticks(np.arange(0,1.2,0.2))plt.show()
linear, log, symlog, logit, asinh, function: $x^{1/2}$

Total running time of the script: (0 minutes 1.935 seconds)

Gallery generated by Sphinx-Gallery