FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

tight_layout does not work with set_visible(False) · Issue #8225 · matplotlib/matplotlib · GitHub

Repository navigation

tight_layout does not work with set_visible(False) #8225

Closed

Description

Bug report

Bug summary

  • tight_layout() cooperates with axis('off') but not with set_visible(False).
  • cf. pandas#9351

Code for reproduction

This code fails:

import matplotlib.pyplot as plt
f, axarr = plt.subplots(2, 2)
axarr[1][1].set_visible(False)
plt.tight_layout()

This code succeeds:

import matplotlib.pyplot as plt
f, axarr = plt.subplots(2, 2)
axarr[1][1].axis('off')
plt.tight_layout()

Actual outcome

AttributeError: 'NoneType' object has no attribute 'is_bbox'

Expected outcome

Activity

  1. WeatherGod commented on Mar 8, 2017

    Member

    Looks like the tight_layout code is iterating over all of the subplots rather than just the visible ones

  2. WeatherGod commented on Mar 8, 2017

    Member

    My suspicion is that adding a condition to the list comprehension:

    tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots])
    

    at line 126 of matplotlib.tight_layout.py should do the trick.

  3. added this to the milestone on Mar 8, 2017
  4. tacaswell commented on Mar 10, 2017

    Member

    Those two commands do very different things, axis('off') makes the spines invisible, but everything else is still visible ex

    fig, ax = plt.subplots()
    ax.plot(range(5))
    ax.axis('off')

    gives

    where are ax.set_visible(False) makes the Axes object (and all of it's children) are not included in the draw tree.

  5. ResidentMario commented on Mar 10, 2017

    ContributorAuthor

    Which is why they look the same output-wise when the plot is empty in the first place (except for dimensional differences), gotcha.

  6. changed the title [-]tight_layout works with axis('off') but not with set_visible(False)[/-] [+]tight_layout does not work with set_visible(False)[/+] on Mar 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL