Код: Выделить всё
import numpy as np import matplotlib.pyplot as plt
c=3.1
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax2 = ax1.twiny()
xticks0 = np.array([1, 1.03, 1.2, 1.5, 2.06, 3.1, 6.2, 15.5], dtype = 'int_')
xvals = np.arange(3, 16, 0.00001)
data = xvals
ax1.plot(xvals, data)
ax1Ticks =xvals
ax2Ticks = xticks0
def tick_function(X):
V = c/X
return ["%.2f" % z for z in V]
ax2.set_xticks(ax2Ticks)
ax2.set_xbound(ax1.get_xbound())
ax2.set_xticklabels(tick_function(ax2Ticks))
ax1.set_xlabel("harmonic order")
ax2.set_xlabel('Wavelength (micrometer)')
ax1.grid(True)
plt.xlim(xmin=3, xmax=15)
plt.tick_params(labelsize = 12 );
plt.show()
Но они не отображаются.
что я хочу:
нижняя ось 3~15 массива
верхняя ось 3.1/нижняя ось (3, 2.5,2,1.5,1,0.5,0.2 ).
Подробнее здесь: https://stackoverflow.com/questions/783 ... econd-axis