Skip to content

[Bug]: Offset notation on y-axis can overlap with a long title #23379

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

Closed
nbeaver opened this issue Jul 1, 2022 · 7 comments
Closed

[Bug]: Offset notation on y-axis can overlap with a long title #23379

nbeaver opened this issue Jul 1, 2022 · 7 comments

Comments

@nbeaver
Copy link
Contributor

nbeaver commented Jul 1, 2022

Bug summary

Offset notation on the y-axis creates a "+1" or similar marker that overlaps a long title.

Code for reproduction

import matplotlib.pyplot as plt
import random
random.seed(123)
x = [n for n in range(100)]
y = [1 + random.random()/1000 for _ in range(100)]
fig, ax = plt.subplots()
ax.plot(x, y, '.-', label="random values near 1.0")
ax.set_title('abcdefghijklmnopqrstuvwxyz' + ' test ' + ' abcdefghijklmnopqrstuvwxyz')
ax.set_ylabel("y")
ax.set_xlabel("x")
ax.legend()
fig.savefig("example.png")
plt.show()

Actual outcome

example

Expected outcome

offset_notation_004

Additional information

There are workarounds such as passing arguments like y=1.03 or pad=15 to set_title() to push the title up manually. However, this should not be necessary as the documentation says "y is determined automatically to avoid decorators on the Axes" (see pull request #17127). Note also that setting constrained_layout=True does not change the output.

Operating system

Windows 10

Matplotlib Version

3.4.3

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

3.9.7

Jupyter version

6.4.5

Installation

conda

@jklymak
Copy link
Member

jklymak commented Jul 1, 2022

I thought we'd fixed this. Can you check 3.5.2? Thanks!

@nbeaver
Copy link
Contributor Author

nbeaver commented Jul 1, 2022

I can reproduce it on 3.5.1. Version 3.5.2 doesn't appear to be in Anaconda's repositories yet so I don't have an easy way to check it on my current machine.

@jklymak
Copy link
Member

jklymak commented Jul 2, 2022

Ok thanks for checking

I'll mark as a good first issue as this should be pretty straight forward addition to the current code that does this.

@jklymak jklymak added the Good first issue Open a pull request against these issues if there are no active ones! label Jul 2, 2022
@nnlnr
Copy link

nnlnr commented Jul 5, 2022

Hi there! First time contributor here, if this issue is still open I'd like to work on it.

@QuLogic
Copy link
Member

QuLogic commented Jul 5, 2022

This is actually fixed by #22063, and will be in 3.6.0. Sorry about that @nnlnr.

@QuLogic QuLogic closed this as completed Jul 5, 2022
@QuLogic QuLogic added status: duplicate and removed Good first issue Open a pull request against these issues if there are no active ones! labels Jul 5, 2022
@QuLogic QuLogic added this to the v3.6.0 milestone Jul 5, 2022
@nnlnr
Copy link

nnlnr commented Jul 5, 2022

no worries - thanks for the follow up

@jklymak
Copy link
Member

jklymak commented Jul 5, 2022

Thanks @QuLogic I was pretty sure this had been fixed, but couldn't find the PR, and forgot to check master...

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

No branches or pull requests

4 participants