Closed
Description
Layout managers seem to have problems with titles containing MathText.
One would expect to have a title which neither overlaps with the axes nor with the figure boundary in all cases depicted below.
tight_layout
multi line title
as expected
multi line title with MathText
The title is a bit squeezed towards the top figure boundary, but does not go beyond it, nor does it overlap the axes. This is somehow still acceptable.
single line title with MathText
Here the title overlaps with the axes. This is in thus far strange because in the case above with multiple lines, this overlap does not occur.
constrained_layout
multi line title
as expected
multi line title with MathText
The title exits the figure. This is not desiredeable.
single line title with MathText
Here the title overlaps with the axes.
code
import matplotlib
import matplotlib.pyplot as plt
plt.rcParams['savefig.facecolor']='#e9f7fd'
def create_bug(title="", constrained_layout=True, i=0):
plt.figure(constrained_layout=constrained_layout)
plt.plot([0,1,2],[0,1,1])
plt.title(title)
if not constrained_layout:
plt.tight_layout()
tx = "tight_layout"
else:
tx = "constrained_layout"
plt.text(0.4,.95, tx, va="center")
plt.savefig(tx+str(i)+".png")
titles = ['line $\sum_{i} x_i$',
'multi-\nline $\sum_{i} x_i$',
'multi-\nline']
for layout in [True, False]:
for i, title in enumerate(titles):
create_bug(title, layout, i)
Matplotlib version
- Operating system: Windows 8.1
- Matplotlib version: 2.2.2, current master
- Matplotlib backend : Qt5Agg
- Python version: 2.7, 3.6
Metadata
Metadata
Assignees
Labels
No labels