python画折线图-python如何画折线图

5f571eacbf1c2385.jpg

python画折线图利用的是matplotlib.pyplot.plot的工具来绘制折线图,这里先给出一个段代码和结果图:# -*- 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(

你可能感兴趣的:(python画折线图-python如何画折线图)