Change Matplotlib Grid Color With RcParams
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
Solution 1:
You would first want to set the grid on, then determine its color
mpl.rcParams.update({"axes.grid" : True, "grid.color": "black"})
Solution 2:
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])
Post a Comment for "Change Matplotlib Grid Color With RcParams"