每天AI你三千遍

matplotlib.pyplot.plot读取数据并制作折线图

2018-04-17  本文已影响350人  AI_Engine

import os

import numpy as np

import matplotlib.pyplot as plt

import sys

reload(sys)

sys.setdefaultencoding('utf-8')

black_path_file =r'xxx'  #数据路径

white_path_file =r'yyy' #数据路径

def achieve_data(path):

'''

数据提取与处理

'''

    return feaValue_list

plt.figure(figsize=(15,5))            #简单理解成制作一个画布即可

plt.xlabel("fea_num")                 #x轴的标签   

plt.ylabel("fea_value")                #y轴的标签

plt.title('white&&black')           #图像的标题

plt.ylim(0,150000)                     #y轴的可见范围

black_fea_list = achieve_data(black_path_file)    

white_fea_list = achieve_data(white_path_file)   

black_fea_array = np.array(black_fea_list)

black_fea_array = np.mean(black_fea_array,axis=0)

white_fea_array = np.array(white_fea_list)

white_fea_array = np.mean(white_fea_array,axis=0)

x = np.linspace(start, stop, how many cell ,endpoint=True)

black_y = black_fea_array

white_y = white_fea_array

plt.plot(x,black_y,color="red",linewidth=2)

plt.plot(x,white_y,color="green",linewidth=1)

plt.xticks([x for x in range(0,78)])        #设计x轴步长

#plt.legend()

plt.show()

上一篇下一篇

猜你喜欢

热点阅读