How is this done? mpl.rcParams['grid.color']
doesn't work.
Default is white:
import matplotlib.pyplot as plt
import matplotlib as mpl
plt.plot([1, 2])
And changing with plt.grid
works fine:
plt.plot([1, 2])
plt.grid(c='black')
But not rcParams
:
mpl.rcParams['grid.color'] = 'black'
plt.plot([1, 2])
您首先要设置网格,然后确定其颜色
mpl.rcParams.update({"axes.grid" : True, "grid.color": "black"})
You should add plt.grid()
in your second example.
Like this :
import matplotlib.pyplot as plt
import matplotlib as mpl
plt.plot([1, 2])
mpl.rcParams['grid.color'] = 'black'
plt.grid()
And further idea: You can also try to use seaborn, it is build on top of matplotlib and has really nice formatations:
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
plt.plot([1, 2])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.