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]: Axes.label_outer() does not work when there is a colorbar #27305

Open
@chrisyeh96

Description

@chrisyeh96

Bug summary

Axes.label_outer() fails to hide axis and tick labels for plots that have a colorbar.

Code for reproduction

importmatplotlib.pyplotaspltimportnumpyasnpx=np.linspace(0,2*np.pi,400)y=np.sin(x**2)fig,axs=plt.subplots(2,2)axs[0,0].plot(x,y)cl2c=axs[0,1].scatter(x,y,c=x)fig.colorbar(cl2c,ax=axs[0,1],label='c-label')axs[1,0].plot(x,y)axs[1,1].plot(x,y)foraxinaxs.flat:ax.set(xlabel='x-label',ylabel='y-label')# try to hide x labels and tick labels for top plots and y ticks for right plots,# but this fails to hide the labels for axs[0, 1] due to its colorbarforaxinaxs.flat:ax.label_outer()

Actual outcome

The output of the code above gives:

image

Expected outcome

I would have expected the plot to look like:

image

This expected plot was created by creating the colorbar after theax.label_outer() calls. However, I would not have expected this to have affected whether the labels/ticks are removed.

fig,axs=plt.subplots(2,2)axs[0,0].plot(x,y)cl2c=axs[0,1].scatter(x,y,c=x)axs[1,0].plot(x,y)axs[1,1].plot(x,y)foraxinaxs.flat:ax.set(xlabel='x-label',ylabel='y-label')# Hide x labels and tick labels for top plots and y ticks for right plots.foraxinaxs.flat:ax.label_outer()fig.colorbar(cl2c,ax=axs[0,1],label='c-label')fig.tight_layout()

Additional information

No response

Operating system

Ubuntu 20.04.5 LTS

Matplotlib Version

3.8.0

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

Python 3.11.6

Jupyter version

7.0.6

Installation

conda

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