用marplotlib绘制不会显示列表中的所有项目

时间:2018-09-21 15:05:12

标签: python matplotlib

嘿,我有一个关于matplotlib的怪异问题,我有这个功能:

def line_plot(results):
    gen_eight = all_of_g(results, 8)
    gen_sixteen = all_of_g(results, 16)
    gen_thirty_two = all_of_g(results, 32)
    print(len(gen_eight))
    print(len(gen_sixteen))
    print(len(gen_thirty_two))

    N = 12


    fig, ax = plt.subplots()

    #ind = np.arange(N)    # the x locations for the groups
    #width = 0.15         # the width of the bars

    plt.plot(gen_eight)
    plt.plot(gen_sixteen)
    plt.plot(gen_thirty_two)

    ax.set_xticklabels(('1MB', '4MB', '8MB', '10MB', '16MB', '32MB', '64MB', '100MB', '128MB', '256MB', '512MB', '1GB'))
    plt.tight_layout()
    plt.show()

但是它绘制的是您在下图中看到的内容,三个十二点是长度的印记。因此缺少一半的值。

enter image description here

我发现真正奇怪的是该功能

def bar_plot(results):

    gen_eight = all_of_g(results, 8)
    gen_sixteen = all_of_g(results, 16)
    gen_thirty_two = all_of_g(results, 32)

    print(gen_eight)


    N = 12


    fig, ax = plt.subplots()

    ind = np.arange(N)    # the x locations for the groups
    width = 0.30         # the width of the bars
    p1 = ax.bar(ind, gen_eight, width, color='r')
    p2 = ax.bar(ind+width, gen_sixteen, width, color='y')
    p3 = ax.bar(ind+width+width, gen_thirty_two, width, color='b')



    #ax.set_title('Scores by group and gender')
    ax.set_xticks(ind + width / 2)
    ax.set_xticklabels(('1MB', '4MB', '8MB', '10MB', '16MB', '32MB', '64MB', '100MB', '128MB', '256MB', '512MB', '1GB'))

    plt.xticks(rotation=75)

    ax.legend((p1[0], p2[0], p3[0]), ('g=8', 'g=16','g=32'))
    ax.autoscale_view()
    plt.ylabel('time (ms)')
    plt.xlabel('Data Size')
    plt.yscale("log", nonposy='clip')
    plt.tight_layout()
    fig.savefig('NOT_SHOWING')

    plt.show()

按原样工作并绘制图形。我希望有人可以帮助我

enter image description here

0 个答案:

没有答案