0

I have the following plot in which the X range is very wide and the shape of the graph near 1 MeV to 0.1 MeV is suppressed.

I want a plot where the X scale has equal separation (or equal grid) between 10,1,0.1 MeV. enter image description here

tmdavison
  • 64,360
  • 12
  • 187
  • 165
Anurag Mishra
  • 11
  • 1
  • 1
  • where is your current code snippet – phoenix Jan 29 '16 at 08:07
  • Possible duplicate of [Plot logarithmic axes with matplotlib in python](http://stackoverflow.com/questions/773814/plot-logarithmic-axes-with-matplotlib-in-python) – Mel Jan 29 '16 at 08:46

2 Answers2

4

You can use matplotlib's semilogx function instead of plot to make the x axis logarithmic.

Here's a short example:

import matplotlib.pyplot as plt
import numpy as 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

tmdavison
  • 64,360
  • 12
  • 187
  • 165
2

also consider ax.set_xscale("log") http://matplotlib.org/examples/pylab_examples/aspect_loglog.html

cattt84
  • 941
  • 1
  • 10
  • 17