python-科研绘图系列(6)-深度模型准确率,误差收敛曲线图;双坐标绘图;双坐标图例放置在一个框中;带95%置信区间的曲线图

1.绘制双坐标


import matplotlib.pyplot as plt
import numpy as np
import  re
from scipy import stats


ax1=fig.add_subplot(1,1, iii)
lns1=ax1.plot(mean[:long], color='darkblue', linewidth=2, linestyle='-',label='ZZZZ Acc')##画准确率曲线
ax2=ax1.twinx()
lns4=ax2.plot(mean[:long], color='darkolivegreen',  linewidth=2,linestyle='-',label='ZZZZ Loss') #画损失曲线

2.双坐标图例放置在一个框中

lns1=ax1.plot(mean[:long], color='darkblue', linewidth=2, linestyle='-',label='ZZZZ Acc')
lns2=ax1.plot(mean[:long], color='orange', linewidth=2, linestyle='-',label='XXXX Acc')
lns3=ax2.plot(mean[:long], color='crimson',  linewidth=2,linestyle='-',label='XXXX Loss')
lns4=ax2.plot(mean[:long], color='darkolivegreen',  linewidth=2,linestyle='-',label='ZZZZ Loss')

lns = lns1 + lns2 + lns3+lns4
labs = [l.get_label() for l in lns]
ax1.legend(lns, labs, loc=0,bbox_to_anchor=(1,1.1),ncol=4,labelspacing=1,columnspacing=0.4,fontsize=16)

3.带95%置信度曲线

mean, std = np.mean(A, 0), np.std(A, 0)#计算平均值和标准差
lns1=ax1.plot(mean[:long], color='darkblue', linewidth=2, linestyle='-',label='ZZZZ Acc')#画平均值曲线
conf_intveral = stats.norm.interval(0.95, loc=mean, scale=std)#计算95%的上下区间
x = np.arange(0, 150)
ax1.fill_between(x[:long], conf_intveral[0][:long], conf_intveral[1][:long], color='deepskyblue', alpha=1)#填充区间

4.可视化结果

python-科研绘图系列(6)-深度模型准确率,误差收敛曲线图;双坐标绘图;双坐标图例放置在一个框中;带95%置信区间的曲线图_第1张图片

你可能感兴趣的:(可视化,plot)