8000 ticks disappear depending on constrained_layout.h_pad value · Issue #14071 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
ticks disappear depending on constrained_layout.h_pad value #14071
Closed
@pharshalp

Description

@pharshalp

Bug report

Bug summary
For a very specific set of circumstances (please see the code snippet), some of the yticks disappear when using constrained_layout with a "large" h_pad value. This happens only when using v3.1rc and doesn't show up for v3.0.3 (might be related to #14054?, I am not sure).

Code for reproduction
I have tried to strip down my plotting script to the bare minimum code required to reproduce the bug. I am not sure what portion of the code is responsible for triggering this behavior.

import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = (3.5, 3.9)
plt.rcParams['figure.constrained_layout.use'] = True
plt.rcParams['figure.constrained_layout.h_pad'] = 3/72
plt.rcParams['axes.titlepad'] = 10

fig, ax = plt.subplots()
ax.plot([0, 0], 'C0', label='label_1')
ax.plot([0, 0], 'C1', label='label_2')

ax.set_ylabel(r'ylabel')
ax.set_xlabel(r'xlabel')
ax.set_title(r'Multiline title containing math'+'\n'+r'{$\frac{x}{y}$}')

ax.set_ylim([0, 0.008])
ax.grid()
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.2))
fig.savefig('temp.png')

Actual outcome
temp

After reducing h_pad to plt.rcParams['figure.constrained_layout.h_pad'] = 1/72, the yticks do reappear!

temp

# If applicable, paste the console output here
#
#

Expected outcome

Matplotlib version

  • Operating system: Mac OS
  • Matplotlib version: '3.1.0rc1'
  • Matplotlib backend (print(matplotlib.get_backend())):
  • Python version: 3.7.3
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0