Closed
Description
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
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
Labels
No labels