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

Adding Text Annotation when Co-plotting Shrinks Subplots when Tight Layout is Applied #18098

Closed
@Aerovet

Description

@Aerovet

Bug report

Bug summary

Vertical annotations shrink subplots when a figure handle'stight_layout is set to True. The expectation is that annotations would overlap the subplots.

Looking at the documentation...

https://matplotlib.org/3.2.2/tutorials/intermediate/tight_layout_guide.html#caveats

tight_layout() only considers ticklabels, axis labels, and titles. Thus, other artists may be clipped and also may overlap

With that in mind,tight_layout should not considerText annotations, and shouldn't adjust the subplot size when added.

Code for reproduction

importmatplotlib.pyplotaspltimportnumpyasnpx=np.linspace(0,np.pi*2,1000)y=np.sin(x)dy=np.cos(x)dy2=-np.sin(x)forbin [False,True]:h,ax=plt.subplots(3,1,sharex=True)h.set_tight_layout(b)ax[0].plot(x,y)ax[1].plot(x,dy)ax[2].plot(x,dy2)ax[2].annotate(s=f'Annotation When Tight Layout is{b}',xy= (np.pi,-1),rotation='vertical')

Actual outcome

image

Expected outcome

In this case,tight_layout is set to FALSE just to see visually what it looks like with the text overlayed

image

Matplotlib version

  • Operating system: CentOS Linux 7 (Core)
  • Matplotlib version: 3.2.2
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.8.3
  • Jupyter version (if applicable):
  • Other libraries: numpy 1.18.5

conda

conda-forge

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp