matplotlib画图2

来源:互联网 发布:惠普笔记本散热软件 编辑:程序博客网 时间:2024/06/06 08:43
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)表示相对位置

这里写图片描述

原创粉丝点击