In [1]:
%pylab inline
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import rcParams
In [2]:
fig = plt.figure(figsize=[15,1])
ax1 = fig.add_subplot(111)
ax2 = ax1.twiny()
nm_tick_locations = np.array([200.+i for i in xrange(0,1800,100)])
def tick_function(X):
V = 1240/X
return ["%.2f" % z for z in V]
ax2.set_xticks(nm_tick_locations)
ax1.set_xticks(nm_tick_locations)
ax2.set_xticklabels(tick_function(nm_tick_locations))
ax1.set_yticks([])
ax1.set_xlim([200,2000])
ax1.set_xlabel("Wavelength, [nm]")
ax2.set_xlim([200,2000])
ax2.grid(True)
ax2.set_xlabel("Energy, [eV]")
plt.show()
In [3]:
fig = plt.figure(figsize=[15,1])
ax1 = fig.add_subplot(111)
ax2 = ax1.twiny()
nm_tick_locations = np.arange(200,1400,100)
ev_tick_locations = np.arange(0.5,6.,0.5)
def tick_location(X):
Y = 1240/X
return Y
ax2.set_xticks(tick_location(ev_tick_locations))
ax1.set_xticks(nm_tick_locations)
ax2.set_xticklabels(ev_tick_locations)
ax1.set_yticks([])
ax1.set_xlim([200,1300])
ax1.set_xlabel("Wavelength, [nm]")
ax2.grid(True)
ax2.set_xlim([200,1300])
ax2.set_xlabel("Energy, [eV]")
plt.show()
In [ ]: