Drawing a plurality of curves Python line graph (matplotlib.pyplot.plot)

  Here I use is matplotlib.pyplot.plot tool to draw a line graph, where the first segment is given a code and map the results:

# -*- coding: UTF-8 -*-
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt

#这里导入你自己的数据
#......
#......
#x_axix,train_pn_dis这些都是长度相同的list()

#开始画图
sub_axix = filter(lambda x:x%200 == 0, x_axix)
plt.title('Result Analysis')
plt.plot(x_axix, train_acys, color='green', label='training accuracy')
plt.plot(sub_axix, test_acys, color='red', label='testing accuracy')
plt.plot(x_axix, train_pn_dis,  color='skyblue', label='PN distance')
plt.plot(x_axix, thresholds, color='blue', label='threshold')
plt.legend() # 显示图例

plt.xlabel('iteration times')
plt.ylabel('rate')
plt.show()
#python 一个折线图绘制多个曲线

Write pictures described here
  Here I talk about matplotlib.pyplot.plot () method is used, attach a first official document link , and then I said, where possible, to use some of the parameters, parameter optional content I will not expand, we can go above that connection Richards:

  • color: color curve, blue, green, red, etc.
  • label: the legend, this parameter content to customize it, note that if write this parameter must be coupled with plt.legend (), and then after plt.show () is useful only!
  • lineStyle: curve style, '-', '-', ':', etc.
  • linewidth: the width of the curve, can be custom
  • marker: marker style, 'o', 'x', that is to say the specific symbols will be marked on the curve, "point", so that it is easy to observe that the curve is where the anchor
  • markersize: size marker point can be custom

  There are aspects of the content of the follow-up charts will continue to update ~

Published 40 original articles · won praise 44 · views 90000 +

Guess you like

Origin blog.csdn.net/Site1997/article/details/79180384