Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

linespacing of multiline texts. #2078

Open
leejjoon opened this Issue · 3 comments

3 participants

@leejjoon
Owner

The linespacing of multiline text in the current master branch needs some improvement.

Consider a following example,

import matplotlib.pyplot as plt
plt.figure(figsize=(7,3))
plt.text(0.2, 0.5, "TpTpTp\n$M$\nTpTpTp", size=20,
         ha="center", va="top")

plt.text(0.5, 0.5, "TpTpTp\n$M^{M^{M^{M}}}$\nTpTpTp", size=20,
         ha="center", va="top")

plt.text(0.8, 0.5, "TpTpTp\n$M_{q_{q_{q}}}$\nTpTpTp", size=20,
         ha="center", va="top")

plt.xlim(0, 1)
plt.ylim(0, 0.8)
plt.show()

Current master (and mdboom's issue2070 branch) produces following.

test_multiline_linespacing_master

Note that superscrips and subscripts overwarp with the line above and below.

In mpl 1.2,

test_multiline_linespacing_mpl1 2

The second looks good, though 3rd still overwrapps.

The desired behavior is (at least to me)

test_multiline_linespacing_okay

I have a working solution based on the v1.2.x branch. Once mdboom's issue2070 branch is merged into master, I will rebase and make a PR.

@leejjoon leejjoon was assigned
@mdboom
Owner

@leejjoon: Can you push your 1.2.x-based solution to your fork? I'd like to have a look to determine whether it makes sense to get into the 1.3.0 release candidate.

@leejjoon
Owner

I pushed my changes after rebasing it to the current master (which incorporates your issue2070 branch).

https://github.com/leejjoon/matplotlib/commits/fix-text

There is subtle difference in how linespacing is treated but this should be a very minor issue. For example, what do we expect when linespacing=0.

On the other hand, I guess my change preserve most of the behavior from v1.2 which is changed in the current master (e.g., #2084).

Anyhow, I guess this issue can be closed?

@tacaswell
Owner

@leejjoon Do we want to pull that commit in still?

@tacaswell tacaswell added this to the v1.5.x milestone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.