You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Problems with text that is just a LaTeX minus sign #4147
I just discovered that a legend with label '$-$', i.e., a single math-mode minus sign, has a number of problems in png output (which also is problematic for ipython notebook inline plots, but the error is independent of that). The exact problem depends on the dpi that the figure is saved with. Here's a minimal example to reproduce it:
while for other settings of dpi, the PNG is generated but the minus sign does not show up (i.e., the legend is empty). Both only happens if the minus sign is the only character in the legend - although it also happens with two minus signs $--$, and even a dash and a minus sign -$-$, but not with only a dash -, or if I add any other character (as far as I have tested).
The exact settings of dpi where I get the error and where the minus sign disappears from the output are apparently system-dependent, but it always disappears for high enough dpi (>93 on one system), and the errors typically show up in the range 120<dpi<140 - for higher dpi, there is again no error, but the symbol is not shown either.
I have tested this on two different systems (OS X with matplotlib 1.4.2 from MacPorts and Red Hat with matplotlib 1.4.3 from anaconda), and with both python 2.7 and python 3.4 on the OS X system, and it shows up on all of them.
I was looking through the open issues and realized that it could be related to #3374, and indeed it also shows up with just a text call, so an even more minimal example is
Hmm... Strangely, I can't reproduce on 1.4.2 or 1.4.3 on Mac or Linux. Do you have anything special about your fonts happening, or anything in matplotlibrc? What version of Freetype?
@mdboom Hmm, surprising - I don't even have a .matplotlibrc, so nothing special there. I haven't done anything special with the fonts either (at least as far as I can remember, but they're fairly new systems, so I think I would). On OS X, I have freetype 2.5.5 from macports, on Red Hat (actually CentOS 6.6 I just realized), I have freetype 2.4.10 from anaconda. Any idea what else I could/should check?
I'm happy @jenshnielsen could reproduce it at least.
Yeah -- just moved to freetype 2.5.5 on both systems and still no breakage for me.
I wouldn't be surprised if this is fixed already on master -- this does go through code paths that were pretty heavily rewritten. Could you try testing git master to see if that resolves your issue?
It would be nice to make a bugfix for 1.4.x if it's easy, but we don't currently have plans for another 1.4.x release at the moment.
I just tested with matplotlib master (installed in a clean virtualenv), and indeed I do not get the exceptions anymore (i.e., it doesn't crash with any setting of dpi). But the minus sign still disappears for dpi>93 or so. So now it simply fails silently in all cases, while before it sometimes at least gave an error...
Activity
[-]Problems with LaTeX minus sign in legend[/-][+]Problems with text that is just a LaTeX minus sign[/+]jfeist commentedon Feb 23, 2015
I was looking through the open issues and realized that it could be related to #3374, and indeed it also shows up with just a
textcall, so an even more minimal example isThe only difference seems to be that the error now shows up at different dpi values (maybe because of different text sizes?).
I have updated the title to reflect this.
mdboom commentedon Feb 23, 2015
Hmm... Strangely, I can't reproduce on 1.4.2 or 1.4.3 on Mac or Linux. Do you have anything special about your fonts happening, or anything in matplotlibrc? What version of Freetype?
jenshnielsen commentedon Feb 23, 2015
I can reproduce it with 1.4.3 (python 2.7 on OSX 101.10 freetype 2.5.5) but not on master.
jfeist commentedon Feb 23, 2015
@mdboom Hmm, surprising - I don't even have a .matplotlibrc, so nothing special there. I haven't done anything special with the fonts either (at least as far as I can remember, but they're fairly new systems, so I think I would). On OS X, I have freetype 2.5.5 from macports, on Red Hat (actually CentOS 6.6 I just realized), I have freetype 2.4.10 from anaconda. Any idea what else I could/should check?
I'm happy @jenshnielsen could reproduce it at least.
mdboom commentedon Feb 23, 2015
Yeah -- just moved to freetype 2.5.5 on both systems and still no breakage for me.
I wouldn't be surprised if this is fixed already on master -- this does go through code paths that were pretty heavily rewritten. Could you try testing git master to see if that resolves your issue?
It would be nice to make a bugfix for 1.4.x if it's easy, but we don't currently have plans for another 1.4.x release at the moment.
jfeist commentedon Feb 23, 2015
I just tested with matplotlib master (installed in a clean virtualenv), and indeed I do not get the exceptions anymore (i.e., it doesn't crash with any setting of dpi). But the minus sign still disappears for dpi>93 or so. So now it simply fails silently in all cases, while before it sometimes at least gave an error...
mdboom commentedon Feb 23, 2015
Ah -- well there's something I can reproduce. Now onto a solution...
jenshnielsen commentedon Feb 23, 2015
I can reproduce that too. However, the error message only shows up sporadically and only when calling save together with the inline backend.
Test based on matplotlib#4147
jfeist commentedon Feb 25, 2015
Thanks for the quick fix! I can confirm it also works for me. However, I noticed that #3374 is not fixed by this. I'll provide more details there.