python 2.7 - Using a logarithmic scale in matplotlib -


i have following plot in x range wide , shape of graph near 1 mev 0.1 mev suppressed.

i want plot x scale has equal separation (or equal grid) between 10,1,0.1 mev. enter image description here

you can use matplotlib's semilogx function instead of plot make x axis logarithmic.

here's short example:

import matplotlib.pyplot plt import numpy np  x = np.arange(0.01,14,0.01) y = np.log(100*x)  fig,(ax1,ax2) = plt.subplots(2)  ax1.plot(x,y) ax1.set_xlim(x[-1],x[0]) ax1.set_title('plot')  ax2.semilogx(x,y) ax2.set_xlim(x[-1],x[0]) ax2.set_title('semilogx')  plt.show() 

enter image description here


Comments