双Y轴折线图
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
x = [1, 2, 5, 10, 15, 20]
y1 = [0.8876, 0.9177, 0.9200, 0.9171, 0.9102, 0.9006]
y2 = [0.6226, 0.6311, 0.6346, 0.6219, 0.6174, 0.6106]
fig, ax1 = plt.subplots()
line1, = ax1.plot(x, y1, color=sns.xkcd_rgb["pale red"], linestyle='-', label='mean')
p1 = ax1.scatter(x, y1, color=sns.xkcd_rgb["pale red"], marker='v', s=30, label='mean')
ax2 = ax1.twinx()
line2, = ax2.plot(x, y2, color=sns.xkcd_rgb["denim blue"], linestyle='-', label='sum')
p2 = ax2.scatter(x, y2, color=sns.xkcd_rgb["denim blue"], marker='o', s=30, label='sum')
ax1.set_xlabel("yead", fontsize=12)
ax1.set_title("title stats", fontsize=14)
ax1.set_xticks(np.array(x))
ax1.set_ylabel("mean", fontsize=12)
ax1.set_yticks(np.arange(0.88, 0.93, 0.01))
ax2.set_ylabel("sum", fontsize=12)
ax2.set_yticks(np.arange(0.60, 0.64, 0.01))
ax1.yaxis.label.set_color(line1.get_color())
ax2.yaxis.label.set_color(line2.get_color())
ax1.tick_params(axis='y', colors=line1.get_color())
ax2.tick_params(axis='y', colors=line2.get_color())
plt.legend(handles=[p1, p2])
plt.show()
