How do I draw a grid onto a plot in Python?

前端 未结 5 974
挽巷
挽巷 2020-12-04 06:06

I just finished writing code to make a plot using pylab in Python and now I would like to superimpose a grid of 10x10 onto the scatter plot. How do I do that?

My cur

5条回答
  •  盖世英雄少女心
    2020-12-04 06:57

    Using rcParams you can show grid very easily as follows

    plt.rcParams['axes.facecolor'] = 'white'
    plt.rcParams['axes.edgecolor'] = 'white'
    plt.rcParams['axes.grid'] = True
    plt.rcParams['grid.alpha'] = 1
    plt.rcParams['grid.color'] = "#cccccc"
    

    If grid is not showing even after changing these parameters then use

    plt.grid(True)
    

    before calling

    plt.show()
    

提交回复
热议问题