matplotlib画图2


fig, ax = plt.subplots(figsize=(10, 8))
plt.grid()
line1 = ax.plot(t, eye_dice, linewidth=1, label='eye_dice', color='darkorange')
line2 = ax.plot(t, len_dice, linewidth=1, label='len_dice', color='m')

line3 = ax.plot(t, nerve_dice, linewidth=1, label='nerve_dice', color='g')
line4 = ax.plot(t, average_loss, linewidth=1, label='average_loss', color='y')

line5 = ax.plot(t, eye_dice_val, linewidth=1, label='eye_dice_val', color='r')
line6 = ax.plot(t, len_dice_val, linewidth=1, label='len_dice_val', color='magenta')

line7 = ax.plot(t, nerve_dice_val, linewidth=1, label='nerve_dice_val', color='aqua')
line8 = ax.plot(t, average_loss_val, linewidth=1, label='average_loss_val', color='deepskyblue')

plt.title('eye_len_nerve_loss_and_dice')
plt.xlabel('epochs')
plt.ylabel('loss')

plt.xlim([0.0, epochs[-1]+1])
plt.ylim([0.0, 1])

ax.legend(loc='lower right', ncol=3, bbox_to_anchor=(1, 0))
plt.show()
ax.legend(loc='lower right', ncol=3, bbox_to_anchor=(1, 0))

参数:
loc参数(位置参数):

‘North’             图例标识放在图顶端
‘South’            图例标识放在图底端
‘East’               图例标识放在图右方
‘West’              图例标识放在图左方
可叠加使用
‘NorthEast’       图例标识放在图右上方(默认)
‘NorthOutside’          图例标识放在图框外侧上方
‘SouthWestOutside’  图例标识放在图框外侧左下方
‘Best’                      图标标识放在图框内不与图冲突的最佳位置
‘BestOutside’           图标标识放在图框外使用最小空间的最佳位置

ncol表示行数
bbox_to_anchor=(1, 0)表示相对位置

这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值