我无法显示正确的arrhenius情节。我应该得到一条直线,但我一直在曲线上。我的数据如下:
0.00 , 0.0658
100.00 , 0.4692
200.00 , 1.4577
300.00 , 3.0489
400.00 , 5.1213
500.00 , 7.5221
600.00 , 10.1170
其中左列是开尔文温度,右列是反应速率。
这是我创建的代码:
from pylab import *
from scipy import *
experimentinput = loadtxt("RateT.txt", delimiter=",")
experiment = transpose(experimentinput)
#converting celcius to kelvin
celcius = experiment[0]
x_data = celcius + 273.15
y_data = experiment [1]
#inverting x-axis
plt.gca().invert_xaxis()
#creating labels
xlabel("1/T (K)")
ylabel("Reaction Rate")
#plotting...
plot(x_data, y_data)
#making the y-axis logarythmic
semilogy()
grid()
show()
我有什么问题吗?任何帮助表示赞赏。
答案 0 :(得分:1)
答案 1 :(得分:0)
正如DanHickstein所说,温度数据应先倒置。
如果你的x_data是np.ndarray类型,那么这样的东西就可以了。
#plotting...
plot(x_data**-1, y_data)
否则,请尝试:
#plotting...
plot([x**-1 for x in x_data], y_data)
答案 2 :(得分:0)
我也在努力创建一个阿累尼乌斯情节。我在下面找到了解决方案,我认为它很灵活。主刻度线位于两个轴的相同位置,此外,可以添加多个副刻度线。
import matplotlib.pyplot as plt
import numpy as np
# Number of Minor Ticks
numticks = 50
fig, ax = plt.subplots()
# Some random data
ax.plot([1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6],
[1e-1, 5e-1, 1e0, 5e0, 1e1, 5e1, 1e2, 5e2, 1e3, 5e3, 1e4])
# Set style for axis
ax.semilogy()
ax.set_xlabel("rez. Temperature 1000/T (1/K)")
ax.set_ylabel("Data Value (a.u.)")
ax.set_xlim([1, 6])
# Setup 2nd axis for Temperature scale
fig.canvas.draw()
ax2 = ax.twiny()
axmin, axmax = ax.get_xlim()
ax2.set_xlim(axmin, axmax)
# Calculate Major Ticks
ax2_labels = []
for item in ax.get_xticklabels():
l = 1000 / float(item.get_text())
l = "{:3.0f}".format(l)
ax2_labels.append(l)
ax2.set_xticklabels(ax2_labels)
ax2.set_xlabel("Temperature (K)")
# Minor Ticks
dtick = (1/ axmin - 1/ axmax) / numticks
minorticks = np.reciprocal([1/ axmax + i * dtick for i in range(numticks)])
ax2.set_xticks(minorticks, minor=True)
plt.show()