Skip to content

[Bug]: PaddedBox not working #24620

Open
Open
@oscargus

Description

@oscargus

Bug summary

PaddedBox https://matplotlib.org/stable/api/offsetbox_api.html#matplotlib.offsetbox.PaddedBox doesn't look like it is working properly.

Code for reproduction

import matplotlib.pyplot as plt
from matplotlib.offsetbox import PaddedBox, AnchoredText

fig, ax = plt.subplots()

at = AnchoredText("foo",  'upper left')
pb = PaddedBox(at, pad=1, patch_attrs={'facecolor' : 'r'}, draw_frame=True)

ax.add_artist(pb)
fig.show()

Actual outcome

paddedbox

Expected outcome

Red box is at same location as text.

Additional information

It seems like the sizing is working OK (using a longer string will change the size accordingly), but that the positioning is not working.

Also, not passing pad leads to an error, so it should probably be 0. as default rather than None.

Operating system

No response

Matplotlib Version

main

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

git checkout

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