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

Default behavior of AnchoredSizeBar gives wrong size #20344

Open
@SF73

Description

@SF73

Bug report

Bug summary

When size_vertical is provided, the resulting sizebar is bigger than expected because of the additional edges have the same
Code for reproduction

importmatplotlib.pyplotaspltfrommpl_toolkits.axes_grid1.anchored_artistsimportAnchoredSizeBarfig,ax=plt.subplots()fig, (ax,bx)=plt.subplots(2,1)wrong_scalebar=AnchoredSizeBar(ax.transData,.2,'','lower left',pad=0,color='#FF0000',frameon=False,size_vertical=.5,label_top=True)expected_scalebar=AnchoredSizeBar(ax.transData,.2,'','lower left',pad=0,color='#00FF007F',frameon=False,size_vertical=.5,label_top=True)expected_scalebar.size_bar.get_children()[0].set_edgecolor("none")ax.add_artist(wrong_scalebar)ax.add_artist(expected_scalebar)expected_scalebar=AnchoredSizeBar(ax.transData,.2,'','lower left',pad=0,color='#00FF007F',frameon=False,size_vertical=.1,label_top=True)expected_scalebar.size_bar.get_children()[0].set_edgecolor("none")ref_scalebar=AnchoredSizeBar(bx.transData,.2,'','lower left',pad=0,color='#FF0000',frameon=False,size_vertical=0,label_top=True)bx.add_artist(ref_scalebar)bx.add_artist(expected_scalebar)#fig.savefig("bug.png")#fig.savefig("bug.svg")

Actual outcome
bug

Easier to see in vector format but svg are not allowed
bug.pdf

On the first subplot, the current sizebar with size_vertical is drawn in red. As the facecolor is the same as the edgecolor the actual Rectangle is longer than it should be.
On the bottom subplot, the sizebar without size_vertical is drawn in red and the expected one with size_vertical in green.

A quick workaround is currently to set the edgecolor to none if the rectangle is filled.

Matplotlib version

  • Operating system: Win10
  • Matplotlib version : 3.3.2

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp