matplotlib作图不显示网格怎么办

各位大神们,问一下为什么python的matplotlib.pyplot.grid运行时会有网格线,保存后就没有了呢?

求解决办法,谢谢大神们了,感谢🙏

可以保存为有网格线的,参考如下代码:

import matplotlib.pyplot as plt
import numpy as np
      
plt.plot([1, 2, 3])
plt.grid()
  
plt.title('matplotlib.pyplot.grid() function \n', fontweight ="bold")
plt.savefig('plot_test.png')
plt.show()

img