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])

You would first want to set the grid on, then determine its color
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])

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With