8000 Layout managers have problems with titles containing MathText · Issue #11468 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Layout managers have problems with titles containing MathText #11468
Closed
@ImportanceOfBeingErnest

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

tight_layout2

as expected

multi line title with MathText

tight_layout1

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

tight_layout0

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

constrained_layout2

as expected

multi line title with MathText

constrained_layout1

The title exits the figure. This is not desiredeable.

single line title with MathText

constrained_layout0

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

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