I am trying to plot a figure with two x-axis, which are non-linear to each other, with matplotlib. The plot I want to get is like this:
Basically, the age is dependent on red shift. It's non linear and need to be calculated. I want to make both age and red shift as x-axis. How can I make it?
The function twiny()
may be what you're looking for.
import matplotlib.pyplot as plt
plt.loglog(range(100))
ax1 = plt.gca()
ax2 = ax1.twiny()
ax2.set_xticks([100,80,50])
ax2.set_xticklabels(['0','1','2'])
ax1.set_xlabel('redshift')
ax2.set_xlabel('age')
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With