Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]:offsetbox classes have optional arguments that are really not optional #24623

Closed
Milestone
@oscargus

Description

@oscargus

Bug summary

In#24620 it was pointed out that "Also, not passing pad leads to an error, so it should probably be 0. as default rather than None."

This holds for many other classes in theoffsetbox module as well.

Code for reproduction

importmatplotlib.pyplotaspltfrommatplotlib.offsetboximportPaddedBox,AnchoredTextfig,ax=plt.subplots()at=AnchoredText("foo",'upper left')pb=PaddedBox(at,patch_attrs={'facecolor' :'r'},draw_frame=True)ax.add_artist(pb)fig.show()

Actual outcome

Traceback (most recent call last):  File "C:\Users\Oscar\matplotlib\lib\matplotlib\backends\backend_qt.py", line 454, in _draw_idle    self.draw()  File "C:\Users\Oscar\matplotlib\lib\matplotlib\backends\backend_agg.py", line 400, in draw    self.figure.draw(self.renderer)  File "C:\Users\Oscar\matplotlib\lib\matplotlib\artist.py", line 74, in draw_wrapper    result = draw(artist, renderer, *args, **kwargs)  File "C:\Users\Oscar\matplotlib\lib\matplotlib\artist.py", line 51, in draw_wrapper    return draw(artist, renderer)  File "C:\Users\Oscar\matplotlib\lib\matplotlib\figure.py", line 3070, in draw    mimage._draw_list_compositing_images(  File "C:\Users\Oscar\matplotlib\lib\matplotlib\image.py", line 131, in _draw_list_compositing_images    a.draw(renderer)  File "C:\Users\Oscar\matplotlib\lib\matplotlib\artist.py", line 51, in draw_wrapper    return draw(artist, renderer)  File "C:\Users\Oscar\matplotlib\lib\matplotlib\axes\_base.py", line 3157, in draw    mimage._draw_list_compositing_images(  File "C:\Users\Oscar\matplotlib\lib\matplotlib\image.py", line 131, in _draw_list_compositing_images    a.draw(renderer)  File "C:\Users\Oscar\matplotlib\lib\matplotlib\offsetbox.py", line 544, in draw    w, h, xdescent, ydescent, offsets = self.get_extent_offsets(renderer)  File "C:\Users\Oscar\matplotlib\lib\matplotlib\offsetbox.py", line 537, in get_extent_offsets    pad = self.pad * dpicorTypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

Expected outcome

No exception. A sensible default value provided.

Additional information

This seems to hold for manypad parameters, but there are others as well. For example, for the packers, I think all numerical arguments must have a value, although they are listed as optional, soNone will be used for computations unless provided.

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

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp