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
Problems with text that is just a LaTeX minus sign #4147
Comments
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 import matplotlib.pyplot as plt
plt.text(0.5,0.5,'$-$')
plt.savefig('test.png',dpi=150) The 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. |
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? |
I can reproduce it with 1.4.3 (python 2.7 on OSX 101.10 freetype 2.5.5) but not on master. |
@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... |
Ah -- well there's something I can reproduce. Now onto a solution... |
I can reproduce that too. However, the error message only shows up sporadically and only when calling save together with the inline backend. |
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. |
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:For some settings of dpi, I get an error message with a traceback ending in
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.
The text was updated successfully, but these errors were encountered: