在折线图上绘制误差

时间:2020-05-04 20:04:39

标签: python pandas matplotlib pytorch seaborn

这是我当前的图表:

enter image description here

我想做的是在执行验证测试的橙色线上添加错误栏...

这是原始变量的样子

train : list of tuples where the first position is batch number and second is the 
        associated loss
        e.g. [(batch, loss), (batch, loss), ...]
test  : list of tuples where the first position is batches processed when the  
        validation was conducted, and the second position is a list of batch losses
        e.g. [(batch, [loss, loss, ...]), (batch, [loss, loss, ...]), ...]

这是我制作剧情的方式

plt.style.use('ggplot')
df_train = pd.DataFrame(train, columns=["Batch","Train"])
df_val   = pd.DataFrame([(batch,sum(losses)/len(losses)) for batch, losses in test], # avg losses from test cycle
                         columns=["Batch","Test"])
data  = df_train.merge(df_val, "outer").sort_values("Batch")
data.interpolate(method="linear").plot(x="Batch", color=["#2976bf","#d57f2e"])

我应该以某种方式在此图上叠加plt.errorbar图吗?解决此问题的正确方法是什么?如果有更好的工具,我很乐意使用其他绘图库。

0 个答案:

没有答案