Matplotlib使用手册

# # 折线图
# # coding:utf-8
# import numpy as np
# from matplotlib import pyplot as plt
#
# ########### 建议每2万批次显示一次 ############
# # local-all-attention的两项(acc和ppl)
# x1 = np.arange(20, 230, 20)   # local-all-attention的横坐标
# acc1 = [50.2458,  52.9601, 55.0572,  56.6326,  57.0941,
#             57.2346,  57.2396, 57.2998, 57.3048,  57.3099, 57.3149]
# ppl1 = [16.3314,  13.0203, 10.5805,  9.93412,  9.76688,
#             9.74388,  9.74002,  9.73403,  9.73349, 9.73305,  9.73298]
#
# # local-attention的两项(acc和ppl)
# x2 = np.arange(20, 220, 20)   # local-attention的横坐标
# acc2 = [45.0532, 43.8391, 54.0136, 55.4686, 56.5723,
#              56.6777, 56.6024, 56.6426, 56.6777, 56.6727]
# ppl2 = [22.8887, 24.5692, 11.5533, 10.6632, 9.80583,
#              9.84389, 9.86903, 9.83289, 9.82772, 9.82563]
#
# # sbd-attention的两项(acc和ppl)
# x3 = np.arange(20, 230, 20)   # local-all-attention的横坐标
# acc3 = [47.6069, 50.9783, 54.7461, 56.8734, 57.34,
#              57.3299, 57.4604, 57.4654, 57.4503, 57.4453, 57.4553]
# ppl3 = [17.8812, 13.4084, 10.824, 9.64026, 9.53139,
#         9.46559, 9.47838, 9.47993, 9.47956, 9.47923, 9.47928]
#
# # sdc-attention的两项(acc和ppl)
# x4 = np.arange(20, 220, 20)   # sdc-attention的横坐标
# acc4 = [44.6317, 47.8326, 50.0702, 51.3044, 51.9015,
#              51.756, 51.766, 51.771, 51.751, 51.751]
# ppl4 = [22.2942, 17.98, 15.1569, 13.8738, 13.6137,
#              13.5732, 13.5927, 13.5995, 13.5979, 13.5975]
#
# # sdc-attention+all_gram的两项(acc和ppl)
# x5 = np.arange(20, 230, 20)   # sdc-attention+all_gram的横坐标
# acc5 = [50.9081, 51.761, 56.3064, 57.2848, 57.4202,
#              57.7815, 57.8818, 57.8467, 57.8768, 57.8667, 57.8617]
# ppl5 = [14.9496, 13.3544, 10.1368, 9.40072, 9.27956,
#               9.23739, 9.25418, 9.27289, 9.27513, 9.27512, 9.27523]
#
# # sdc-alpha-p的两项(acc和ppl)
# x6 = np.arange(20, 220, 20)   # sdc-alpha-p的横坐标
# acc6 = [50.9783, 53.2862, 56.1961, 57.4754, 57.8918,
#              57.9119, 57.7915, 57.8417, 57.8517, 57.8467]
# ppl6 = [17.1848, 14.9464, 11.8971, 10.4621, 10.3654,
#              10.3596, 10.4032, 10.4134, 10.4097, 10.4092]
#
# # sdc-alpha-p5的两项(acc和ppl)
# x7 = np.arange(20, 270, 20)   # sdc-alpha-p的横坐标
# acc7 = [52.1423, 54.5505, 56.171, 58.5139, 58.524,
#              58.6243, 58.6293, 58.6394, 58.6394, 58.6394,
#              58.6394, 58.6394, 58.6394]
# ppl7 = [13.6753, 11.5752, 9.77621, 8.75242, 8.70538,
#              8.69873, 8.71407, 8.71874, 8.72004, 8.72033,
#              8.72039, 8.72035, 8.72034]
#
#
# # s-:方形 , o-:圆形 ;  color: 'r--',  'g--', 'b--', 'c'
# #在当前绘图对象中画图(x轴,y轴,给所绘制的曲线的名字,画线颜色,画线宽度, 画线风格)
# # plt.plot(x,y,label="$sin(x)$",color="red", linewidth=2, linestyle='--')
#
# # local-all-attention
# plt.plot(x1, acc1, 'o-', color='r', label='GlobalAtt')
# # plt.plot(x1, ppl1, 'o-', color='r', label='GlobalAtt')
#
# # local-attention
# plt.plot(x2, acc2, 'v-', color='orange', label='LocalAtt')
# # plt.plot(x2, ppl2, 'v-', color='orange', label='LocalAtt')
#
# # sbd-attention
# plt.plot(x3, acc3, '^-', color='y', label='SBDAtt')
# # plt.plot(x3, ppl3, '^-', color='y', label='SBDAtt')
#
# # sdc-attention
# plt.plot(x4, acc4, '*-', color='g', label='SDCAtt')
# # plt.plot(x4, ppl4, '*-', color='g', label='SDCAtt')
#
# # sdc-attention+all_gram
# plt.plot(x5, acc5, 'h-', color='c', label='SDCAtt+all_gram')
# # plt.plot(x5, ppl5, 'h-', color='c', label='SDCAtt+all_gram')
#
# # sdc-alpha-p
# plt.plot(x6, acc6, 's-', color='b', label='TSDAtt')
# # plt.plot(x6, ppl6, 's-', color='b', label='TSDAtt')
#
# # sdc-alpha-p5
# plt.plot(x7, acc7, 'p-', color='purple', label='ρ-DDAtt')  # purple,violet
# # plt.plot(x7, ppl7, 'p-', color='purple', label='ρ-DDAtt')
#
# # 设置横坐标轴的刻度(纵坐标不需要设置)
# my_x_ticks = np.arange(20, 270, 20)
# plt.xticks(my_x_ticks)
#
# # 横坐标的名字 # Iterations   x1000  纵坐标的名字
# plt.xlabel('Batches (x1000)')
# plt.ylabel('Accuracy')
#
# # 图标题 #图例 , loc=”best”是自动选择放图例的合适位置
# # plt.title("A simple plot")
# plt.legend(loc="best")
#
# #保存图
# path = r'D:\NMT_Code\nematus-local-attention\Learning_curves'
# # plt.savefig(path+"\en_de_ppl.png")
# plt.savefig(path+"\en_de_aac.png")
#
# # 显示图
# plt.show()

import matplotlib.pyplot as plt
import numpy as np
#val_ls = [np.random.randint(100) + i*20 for i in range(7)]
scale_ls = range(8)
index_ls = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']
# plt.bar(scale_ls, val_ls)
_ = plt.xticks(scale_ls,index_ls)  ## 可以设置坐标字
plt.title('Average customer flows Number by Weekdays')

plt.show()

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值