Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ondrejdee opened this issue Nov 27, 2016 · 11 comments
Closed
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
Milestone

Comments

@ondrejdee
Copy link

  • 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

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Nov 29, 2016
@QuLogic
Copy link
Member

QuLogic commented Nov 29, 2016

This is a really easy fix; one needs to add self._linespacing to matplotlib.text.Text.get_prop_tup, but it needs tests, etc., which I don't have time for at the moment, so tagging new-contributor-friendly.

@QuLogic QuLogic added Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues new-contributor-friendly labels Nov 29, 2016
@vincentpham1991
Copy link

Can I take a crack at this? I would like to contribute to matplotlib.

@QuLogic
Copy link
Member

QuLogic commented Dec 7, 2016

Sure, no need to ask, just follow the changes that I outlined and open a PR.

@vincentpham1991
Copy link

I am trying to try out how to test functions in matplotlib. I ran the sample test on the documentation:
python tests.py "matplotlib.tests.test_simplification:test_clipping"

but got the following error:

Python byte-compilation optimization level: 0
Traceback (most recent call last):
    File "tests.py", line 46, in <module>
        success = test(argv=sys.argv[0:1] + extra_args, switch_backend_warn=False)
TypeError: test() got an unexpected keyword argument 'argv'

I am not sure how to proceed if I can't test my changes.

@phobson
Copy link
Member

phobson commented Dec 8, 2016

@vincentpham1991 what OS/platform are you on?

@vincentpham1991
Copy link

I am using Mac OS 10.11.6

@phobson
Copy link
Member

phobson commented Dec 8, 2016

can you describe your setup a little further?
(e.g., how up-to-date is your source branch? are you using virtual or conda environments? which version of python? how did you install your development version of matplotlib?)

@vincentpham1991
Copy link

I solved the issue I mentioned above but am running into another issue:
Whenever I run the test, I get the following error, causing tests that compares against images to fail:

UserWarning: matplotlib is not built with the correct FreeType version to run tests.  Set      
local_freetype=True in setup.cfg and rebuild. Expect many image comparison failures below.
Expected freetype version 2.7.0. Found freetype version 2.6.1. Freetype build type is not local

I pulled from the master branch from github a couple of hours ago, so it should be the latest version. I just pulled again to confirm.

From the package, I ran python setup.py develop.

I am using the base version of python installed by brew. My current version is Python 2.7.10.

I renamed setup.cfg.template to setup.cfg and uncommented:

local_freetype=True

As well as:

tests = True
sample_data = True
toolkits = True

@QuLogic
Copy link
Member

QuLogic commented Dec 8, 2016

Make sure to change setup.cfg before running python setup.py develop (though I prefer pip install -e .).

@vincentpham1991
Copy link

Yes, I made the change to setup.cfg before running the setup.

@tacaswell
Copy link
Member

If you installed, changed the config, and then installed again, it may still be re-using the objects built and linked from the first install. The python builder is smart, but not that smart.

See http://matplotlib.org/devdocs/devel/contributing.html#retrieving-and-installing-the-latest-version-of-the-code

kachonchan added a commit to kachonchan/matplotlib that referenced this issue Mar 1, 2017
Keerush added a commit to Keerush/matplotlib that referenced this issue Apr 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
Projects
None yet
Development

No branches or pull requests

5 participants