Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Milestone
Description
Bug report
Bug summary
Using matplotlib 3.4.1 on a fresh miniconda installation, trying to add a grid to an axis can return an error.
It seems to be linked with the "reset" option of the tick_param function of an axis, if the function has been used just before adding the grid. Activating the option seems to cause the issue; removing the option makes everything work.
Code for reproduction
fig,axes=plt.subplots(1,4,sharey=True)# This doesn't workforaxisinaxes:axis.tick_params(reset=True,axis='both',which='major',labelsize=10,right=False,top=False)foraxisinaxes:axis.grid(color="gainsboro",linestyle='-',linewidth=0.5)axis.set_facecolor('#FCFCFC')# This worksforaxisinaxes:axis.tick_params(reset=False,axis='both',which='major',labelsize=10,right=False,top=False)foraxisinaxes:axis.grid(color="gainsboro",linestyle='-',linewidth=0.5)axis.set_facecolor('#FCFCFC')
Actual outcome
File"C:\ProgramData\Miniconda3\lib\site-packages\matplotlib\axis.py",line1414,ingridgridkw['gridOn']=notself._major_tick_kw['gridOn']KeyError:'gridOn'
Expected outcome
The grid is expected to be added to the figure without any issue, resulting in the following appearance :
Matplotlib version
- Operating system: Windows 10
- Matplotlib version (
import matplotlib; print(matplotlib.__version__)
): 3.4.1 - Matplotlib backend (
print(matplotlib.get_backend())
): Qt5Agg - Python version: 3.9.1
Matplotlib was installed via the anaconda command prompt, usingconda install -c conda-forge matplotlib
.