美文网首页每天AI你三千遍
matplotlib.pyplot.plot读取数据并制作折线图

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

作者: AI_Engine | 来源:发表于2018-04-17 19:57 被阅读350次

    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()

    相关文章

      网友评论

        本文标题:matplotlib.pyplot.plot读取数据并制作折线图

        本文链接:https://www.haomeiwen.com/subject/ubipkftx.html