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]: inset colorbar colours and frame misaligned #29383

Open
@rcomer

Description

@rcomer

Bug summary

Following#29340, when a colorbar is added in an inset axes there is still a small mismatch between the frame and the colours of the colorbar, as shown in thetest image added at #29340. That test uses the toolkitsinset_axes but the problem also appears when usingAxes.inset_axes.

Code for reproduction

From#27763 (comment):

importmatplotlib.pyplotaspltimportnumpyasnpfig,axes=plt.subplots(1,1,layout='constrained')x=np.random.randint(100,size=(30,200))c=axes.imshow(x,origin='lower',cmap='Reds',aspect=1)axins1=axes.inset_axes([0.05,0.8,0.2,0.09])fig.colorbar(c,cax=axins1,orientation="horizontal")fig.savefig('test_single.pdf',bbox_inches='tight')

Actual outcome

image

Expected outcome

Colorbar frame should be lined up with its colours.

Additional information

To reproduce the bug we need

  • Rasterized artist ininset_axes
  • Saving withbbox_inches='tight'
  • Saving as pdf, so perhaps linked to the mixed-mode renderer callingadjust_bbox multiple times viaprocess_figure_for_rasterizing.

Increasing the figure dpi to 300 makes the problem disappear. Also, when I originally wrote the test at#29340 I forgot to set the style. The problem did not show up with classic mode.

I have reproduced with v3.2, so probably this never worked.

Operating system

Ubuntu

Matplotlib Version

main

Matplotlib Backend

QtAgg

Python version

3.12.5

Jupyter version

n/a

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp