X Tutup
Skip to content

Multi-line text instances differing in linespacing not rendered correctly #7523

@ondrejdee

Description

@ondrejdee
  • matplotlib 1.5.3 (pip install)
  • python 2.7.6 (apt-get from ubuntu repository)
  • ubuntu 14.04
  • goal: display 2-line texts which differ by linespacing.
  • issue: when the text instances have the same parameters (coordinates, text string, alpha) except for the linespacing, the second one is displayed over the first one. The linespacing of the first instance is used for the second instance as well.
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt

def two_2line_texts(x1, y1, spacing1, x2, y2, spacing2): 

    text_string = 'line1\nline2'
    plt.text(x1, y1, text_string, linespacing = spacing1, alpha = 0.5)
    plt.text(x2, y2, text_string, linespacing = spacing2, alpha = 0.5)

# fig 1: 
two_2line_texts(x1 = .5, y1 = .5, spacing1 = 2, 
                x2 = .5, y2 = .5, spacing2 = 0.4) 

# fig 2: 
two_2line_texts(x1 = .5, y1 = .5, spacing1 = 0.4, 
                x2 = .5, y2 = .5, spacing2 = 2) 

# fig 3: 
two_2line_texts(x1 = .5, y1 = .5000000001, spacing1 = 0.4, 
                x2 = .5, y2 = .5, spacing2 = 2) 

fig 1:
linespacing_pars1

fig 2:
linespacing_pars2

fig 3:
linespacing_pars3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup