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

Appearance settings

Automatic title placement wrong if parent axes is off the page #18283

Copy link
Copy link
Closed
@jnboehm

Description

@jnboehm
Issue body actions

Bug report

Bug summary
When calculating the extent of a subplot axes, its contents depend on whether title has been set in the axes below, i. e. the unrelated title bleeds into the extent and gets exported when saving while specifying the bbox_inches.

The extent itself doesn't seem to be the problem, but the inclusion of artefacts that should not be included in the plot, and aren't visible in the full figure (in the bounding box) are included and saved when giving an explicit bounding box to fig.savefig.

Code for reproduction

import matplotlib.pyplot as plt
fig, axs = plt.subplots(2, 1)
axs[0].plot([1,2], [3,4])
extent = axs[0].get_window_extent().transformed(fig.dpi_scale_trans.inverted())
fig.savefig('/tmp/expected.png', bbox_inches=extent)
axs[1].set_title('pls ignore me')
# extents are actually unchanged
extent2 = axs[0].get_window_extent().transformed(fig.dpi_scale_trans.inverted())
fig.savefig('/tmp/actual.png', bbox_inches=extent2)
fig.savefig('/tmp/full.png')

Actual outcome
The title of axs[1] is shown.

actual

Expected outcome
It should not be included, as visible in the full picture.

expected
full

Matplotlib version

  • Operating system:
  • Matplotlib version: 3.2.1
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.8.2

Environment has been installed with the default conda channel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: geometry managerLayoutEngine, Constrained layout, Tight layoutLayoutEngine, Constrained layout, Tight layout

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.