8000 Plotting text on 3d axes before tight_layout() breaks tight_layout() · Issue #12687 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Plotting text on 3d axes before tight_layout() breaks tight_layout() #12687
Closed
@sjvrijn

Description

@sjvrijn

Bug report

Bug summary

plt.tight_layout() does not work on 3d plots when adding text before the tight_layout() call, but does work when adding text after. Problem does not occur for 2d plot.

Code for reproduction

import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d

def test1():
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    plt.title('tight_layout() first: correct layout')

    plt.tight_layout()
    ax.text(.5, .5, .5, s='some string')

    plt.show()


def test2():
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    plt.title('ax.text() first: wrong layout + UserWarning')

    ax.text(.5, .5, .5, s='some string')
    plt.tight_layout()

    plt.show()


test1()
test2()

Actual outcome

test1
test2

D:\Python36\lib\site-packages\matplotlib\tight_layout.py:176: UserWarning: Tight layout not applied. The left and right margins cannot be made large enough to accommodate all axes decorations. 
  warnings.warn('Tight layout not applied. The left and right margins '

Expected outcome

Same behavior for both cases.

Matplotlib version

  • Operating system: Windows 10
  • Matplotlib version: 3.0.1
  • Matplotlib backend (module://backend_interagg):
  • Python version: 3.6

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

      0