Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: title position incorrect for polar plot #29381

Closed
@jkittner

Description

@jkittner

Bug summary

When using a polar coordinate system the plot title overlaps with the axis labels. This worked in 3.9.4 and broke with 3.10.0. This commit broke it: 8abe308 via #28300

Code for reproduction

import matplotlib.pyplot as plt

plt.polar([0, 1], [0, 1])
plt.title('My Title')
plt.savefig('output.png')

Actual outcome

The title overlaps the axis labels

grafik

Expected outcome

The title should be above the axis labels

grafik

Additional information

  • This bug happens with the new 3.10 version, but with the 3.9.4 version
    I performed a git bisect using this:
 git bisect start
git bisect good v3.9.4
git bisect bad HEAD

a small test script check.py - there's probably a better way, but that's what I came up with. (Note that the issues also comes up when not using `bbox_inches='tight', but this way it was easier to bisect, since I could instrument the image size)

import matplotlib.pyplot as plt
from PIL import Image

def main():
    plt.polar([0, 1], [0, 1])
    plt.title('My Title')
    plt.savefig('output.png', bbox_inches='tight')
    with Image.open('output.png') as img:
        size = img.size

    if size != (453, 464):
        return 1
    else:
        return 0

if __name__ == '__main__':
    raise SystemExit(main())

finally,

git bisect run python3 check.py

After a few steps it yielded this suspicious commit: 8abe308 (cc @rcomer) which was merged in #28300

Operating system

Ubuntu 22.04

Matplotlib Version

3.10.0.dev1180+gc2d502d219

Matplotlib Backend

agg

Python version

3.13.1

Jupyter version

No response

Installation

git checkout

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.status: confirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions