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

2

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.