Python Matplotlib - how to specify values on y axis?

前端 未结 1 1094
广开言路
广开言路 2020-12-15 03:19

I am new to Python and I need to generate a graph using pyplot and matplotlib like the one in the attached picture. So far I tried it like this:

 import matp         


        
1条回答
  •  囚心锁ツ
    2020-12-15 03:54

    import matplotlib.pyplot as plt
    import numpy as np
    
    x = np.array([0,1,2,3])
    y = np.array([0.650, 0.660, 0.675, 0.685])
    my_xticks = ['a', 'b', 'c', 'd']
    plt.xticks(x, my_xticks)
    plt.yticks(np.arange(y.min(), y.max(), 0.005))
    plt.plot(x, y)
    plt.grid(axis='y', linestyle='-')
    plt.show()
    

    Something like this should work.

    0 讨论(0)
提交回复
热议问题