How To Correctly Plot An Arrhenius Graph?
I am having trouble displaying a correct arrhenius plot. 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
Solution 1:
You forgot to plot 1/temperature(K) in your Arrhenius plot.
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()
Solution 2:
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.
#plotting...
plot(x_data**-1, y_data)
otherwise, try:
#plotting...
plot([x**-1 for x in x_data], y_data)
Solution 3:
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 inrange(numticks)])
ax2.set_xticks(minorticks, minor=True)
plt.show()
Post a Comment for "How To Correctly Plot An Arrhenius Graph?"