2016-01-29 74 views
-1

我有下面的图,其中X范围非常宽,并且抑制了接近1MeV到0.1MeV的图的形状。在matplotlib中使用对数刻度

我想要一个X尺度在10,1,0.1 MeV之间具有相等间距(或相等网格)的情节。 enter image description here

+0

哪里是你当前的代码段 – phoenix

+0

的[剧情数轴与python中matplotlib]可能的复制( http://stackoverflow.com/questions/773814/plot-logarithmic-axes-with-matplotlib-in-python) – Mel

回答

2

你可以用它代替plotmatplotlibsemilogx功能使x轴数。

这里有一个简单的例子:

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