简体   繁体   English

如何正确绘制阿累尼乌斯图?

[英]How to correctly plot an arrhenius graph?

I am having trouble displaying a correct arrhenius plot.我无法显示正确的 arrhenius 图。 I am supposed to get a straight line but am consistently getting a curve.我应该得到一条直线,但一直得到一条曲线。 The data I have is as follows:我的数据如下:

  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

where the left column is temperature in kelvin and the right column is reaction rate.其中左列是以开尔文为单位的温度,右列是反应速率。

This is the code I have created:这是我创建的代码:

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()

Is there something I'm doing wrong?有什么我做错了吗? Any help is appreciated.任何帮助表示赞赏。

You forgot to plot 1/temperature(K) in your Arrhenius plot .您忘记在Arrhenius plot 中绘制 1/temperature(K) 。

Here is a complete cut-and-pastable version of your example:这是您示例的完整可剪切和可粘贴版本:

from pylab import *
from scipy import *
from StringIO import StringIO

data = """
  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"""

celcius,y_data = loadtxt(StringIO(data), delimiter=",",unpack=True)   

#converting celcius to kelvin
kelvin = celcius + 273.15

#creating labels
xlabel("1/T (K)")                       
ylabel("Reaction Rate")

#plotting...
plot(1/kelvin, y_data) 

#making the y-axis logarythmic
semilogy()

grid()
show()

在此处输入图片说明

As DanHickstein has said, temperature data should be inverted a prior ..正如丹希克斯坦所说,温度数据应该提前倒置..

if your x_data is of type np.ndarray, something like this would work.如果你的 x_data 是 np.ndarray 类型,这样的事情会起作用。

 #plotting...
 plot(x_data**-1, y_data)

otherwise, try:否则,请尝试:

 #plotting...
 plot([x**-1 for x in x_data], y_data)

I also was struggling with creating an arrhenius plot.我也在努力创建一个阿伦尼乌斯图。 I found the solution below and I think it's quite flexibel.我找到了下面的解决方案,我认为它非常灵活。 Major Ticks are located at the same position for both axis, additionally, a number of minor ticks can be added.两个轴的主要刻度位于相同的位置,此外,可以添加一些次要刻度。

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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM