import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rcParams
config = {
"font.family": 'serif',
"font.size": 12,
"mathtext.fontset": 'stix',
"font.serif": ['SimSun'],
}
rcParams.update(config)
x = np.arange(1, 24 + 1).reshape(24).tolist()
y1 = x
y2 = np.arange(24, 0, -1).reshape(24).tolist()
fig = plt.figure(figsize=(5, 3))
ax = fig.add_subplot(111)
ax.plot(x, y1, marker='.', label='正比例函数', zorder=2)
ax2 = ax.twinx()
ax2.plot(x, y2, marker='.', color='darkorange', label='反比例函数', zorder=2)
fig.legend(loc='lower right', bbox_to_anchor=(0.7, 0), bbox_transform=ax.transAxes, ncol=1)
ax.grid(zorder=1)
ax.set_xlabel('横坐标')
ax.set_ylabel('纵坐标1')
ax2.set_ylabel('纵坐标2')
ax.set_title('线性函数', fontsize=12)
plt.subplots_adjust(top=0.88, bottom=0.2, right=0.88, left=0.125, hspace=0.2, wspace=0.2)
plt.savefig('正比例函数.svg')
plt.show()
