Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple plot spacing bug: ylabel gets wrongfully removed from plot #12428

Closed
Volker-Weissmann opened this issue Oct 7, 2018 · 2 comments
Closed

Comments

@Volker-Weissmann
Copy link

Bug report

Bug summary

Matplotlib removes part of the plot

Code for reproduction

import matplotlib.pyplot as plt
plt.ylabel("yLabel")
x = [1,4]
n = -4 #bug occurs if n is -4, -5 -6, or 6
y = [1*10**n, 4*10**n]

plt.plot(x,y, "r+")
plt.show()

Actual outcome

-4

As you can see: The ylabel is partly missing

Expected outcome

There should be a "yLabel" written on the y-Axis.

Matplotlib version

  • Operating system: Linux (Ubuntu 18.04)
  • Matplotlib version: 2.2.2
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.6.6
  • Jupyter version (if applicable):
  • Other libraries:

matplotlib was installed via pip3 install matplotlib

@jklymak
Copy link
Member

jklymak commented Oct 7, 2018

Thats why things like constrained_layout and tight_layout are necessary. By default, the axes only makes enough room for "normal" labels, but yours have a lot of decimal places, so the label is off the plot.

plt.figure(constrained_layout=True)

plt.figure(tight_layout=True)

or
plt.savefig(bbox_inches='tight')

are the ways to handle this sort of problem.

Closing because there is nothing automatic we can do to fix this.

@jklymak jklymak closed this as completed Oct 7, 2018
@Volker-Weissmann
Copy link
Author

Sorry, I did not know that these options exist. Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants