python画图(双y4线)

python画图(双y4线)

font1 = {“family” : “Times New Roman”,“weight” : “normal”,“size” : 25,} #设置字体
plt.xlabel(‘Transfer learning data number’,font1)
plt.xticks(fontsize=20)#字体
plt.xticks([0, 1, 2, 3, 4, 5,6,7,8,9,10])#x轴的范围
plt.yticks(fontsize=20)
plt.ylabel(‘MSE(2,3,4)’,font1)
#plt.plot(x0, y_test)
#line2, = ax.plot(x1,mse2, c=‘r’, label=‘Second transfer’)
line2, = ax.plot(x1,mse2, c=‘r’, label=‘2th transfer’,linewidth=3)
plt.scatter(x1, mse2,color=‘r’)
line3, = ax.plot(x1,mse3, c=‘blue’, label=‘3th transfer’,linewidth=3)
plt.scatter(x1, mse3,color=‘blue’)
line4, = ax.plot(x1,mse4, c=‘g’, label=‘4th transfer’,linewidth=3)
plt.scatter(x1, mse4,color=‘g’)
#*plt.plot(x1,mse1, color=‘red’)
#plt.scatter(x1, mse1,color=‘red’)

plt.plot(x1,mse2, color=‘blue’)#scater画点图

plt.scatter(x1, mse2,color=‘blue’)

plt.plot(x1,mse3, color=‘green’)

plt.scatter(x1, mse3,color=‘green’)

plt.plot(x1,mse4, color=‘black’)

plt.scatter(x1, mse4,color=‘black’)

#plt.scatter(x0.numpy(), predict, color=‘red’, label=‘Predicted temperature value’)
ax1 = ax.twinx()#复制x轴
plt.yticks(fontsize=20)
plt.ylabel(‘MSE(1)’,font1)
line1, = ax1.plot(x1,mse1, c=‘orange’, label=‘1th transfer’,linewidth=3)
plt.scatter(x1, mse1,color=‘orange’)

###设置坐标轴的粗细
ax=plt.gca();#获得坐标轴的句柄
ax.spines[‘bottom’].set_linewidth(4);###设置底部坐标轴的粗细
ax.spines[‘left’].set_linewidth(4);####设置左边坐标轴的粗细
ax.spines[‘right’].set_linewidth(4);###设置右边坐标轴的粗细
ax.spines[‘top’].set_linewidth(4);####设置上部坐标轴的粗细

plt.legend(handles=[line1, line2,line3,line4], labels=[‘1th transfer’, ‘2th transfer’,‘3th transfer’,‘4th transfer’],loc=9)#展示标签
#plt.legend(loc=‘center’)
plt.show()python画图(双y4线)_第1张图片

你可能感兴趣的:(python)