How to realize scale Calibration by matplotlib
This article mainly introduces matplotlib how to achieve scale calibration, the article is very detailed, has a certain reference value, interested friends must read it!
1.5. Logarithm or other nonlinear axes
Use plt.xscal () to change the scale of the axis
Import numpy as npimport matplotlib.pyplot as pltfrom matplotlib.ticker import NullFormatter # useful for `logit` scale# Fixing random state for reproducibilitynp.random.seed (19680801) # make up some data in the interval] 0,1 [y = np.random.normal (loc=0.5, scale=0.4, size=1000) y = y [(y > 0) & (y < 1)] y.sort () x = np.arange (len (y)) # plot with various axes scalesplt.figure (1) # linearplt.subplot (221) plt.plot (x Y) plt.yscale ('linear') plt.title (' linear') plt.grid (True) # logplt.subplot plt.plot (x, y) plt.yscale ('log') plt.title (' log') plt.grid (True) # symmetric logplt.subplot (223) plt.plot (x, y-y.mean () plt.yscale ('symlog', linthreshy=0.01) plt.title (' symlog') plt.grid (True) # logitplt.subplot (224) plt.plot (x Y) plt.yscale ('logit') plt.title (' logit') plt.grid (True) # Format the minor tick labels of the y-axis into empty strings with# `NullFormatter`, to avoid cumbering the axis with too many labels.plt.gca (). Yaxis.set_minor_formatter (NullFormatter ()) # Adjust the subplot layout, because the logit one may take more space# than usual, due to y-tick labels like "1-10 ^ {- 3}" plt.subplots_adjust (top=0.92, bottom=0.08, left=0.10, right=0.95, hspace=0.25 Wspace=0.35) plt.show ()
The above is all the content of the article "how to achieve scale scale in matplotlib". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!