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]: aspect ratio control of colorbar Axes fails. #22087

Open
@efiring

Description

@efiring

Bug summary

Previously, a colorbar axes could be created with a specified aspect ratio and adjustable "box". Now it leaves whitespace either at the ends or on the sides.

Code for reproduction

importnumpyasnpimportmatplotlib.pyplotaspltimportmatplotlib.colorbarasmcolorbarfig,axs=plt.subplots(ncols=3,sharey=True)forax,aspectinzip(axs, (20,40,None)):cs=ax.contourf(np.arange(24).reshape((4,6)),levels=[2,4,8,16],extend="both")cax,kw=mcolorbar.make_axes(ax)ifaspectisnotNone:cax.set_aspect(aspect,anchor=(0.8,0.5),adjustable='box')ax.set_title(f"Cbar aspect is{aspect}")else:ax.set_title("No cbar aspect")cbar=fig.colorbar(cs,cax=cax)print(cax.get_aspect(),cax.get_adjustable())fig.savefig("colorbar_aspect.png")

Actual outcome

colorbar_aspect

Expected outcome

E.g., using mpl 3.4.3:
colorbar_aspect_3-4-3

Additional information

The result is even worse with 3.5.0: the first 2 colorbars in the example are blank except for the triangles.

Operating system

OS/X

Matplotlib Version

3.5.1

Matplotlib Backend

No response

Python version

3.7.12

Jupyter version

No response

Installation

conda

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp