two labels on one axis python

Solutions on MaxInterview for two labels on one axis python by the best coders in the world

showing results for - "two labels on one axis python"
Jaiden
02 Aug 2019
1import numpy as np
2import matplotlib.pyplot as plt
3from matplotlib import rc
4rc('mathtext', default='regular')
5
6fig = plt.figure()
7ax = fig.add_subplot(111)
8ax.plot(time, Swdown, '-', label = 'Swdown')
9ax.plot(time, Rn, '-', label = 'Rn')
10ax2 = ax.twinx()
11ax2.plot(time, temp, '-r', label = 'temp')
12ax.legend(loc=0)
13ax.grid()
14ax.set_xlabel("Time (h)")
15ax.set_ylabel(r"Radiation ($MJ\,m^{-2}\,d^{-1}$)")
16ax2.set_ylabel(r"Temperature ($^\circ$C)")
17ax2.set_ylim(0, 35)
18ax.set_ylim(-20,100)
19plt.show()