Skip to content

labelpad is not the spacing between the axis and the label #13487

Closed
@baloe

Description

@baloe

Bug report

Bug summary

The matplotlib documentation for matplotlib.axes.Axes.set_ylabel reads
"labelpad : Spacing in points between the label and the y-axis."
(https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.set_ylabel.html#matplotlib.axes.Axes.set_ylabel)
but in fact it is not the spacing between the label and the y-axis.
It really is the spacing between the label and the ticklabels.

Code for reproduction

import numpy as np
import matplotlib
import matplotlib.pyplot as plt

np.random.seed(19680801)
mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)

fig, ax = plt.subplots()

n, bins, patches = ax.hist(x, 50, normed=1, facecolor='g', alpha=0.75)
ax.set_ylabel('Probability $y$', labelpad=0)
fig.show()

Actual outcome

Much space between y-axis and ylabel.

Expected outcome

No space between y-axis and ylabel.

Matplotlib version

  • Operating system: Ubuntu 16.04.5 LTS 64-bit
  • Matplotlib version: 3.0.2 (conda, build: py36_1002, channel: conda-forge)
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.6.8 (conda, build: h0371630_0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationGood first issueOpen a pull request against these issues if there are no active ones!

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions