Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

KeyError: 'gridOn' in axis.py when axis.tick_params() is used with reset = True #20149

Closed
@Klemet

Description

@Klemet

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 :

image

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp