The GUI plot looks OK when I add plt.show(), but I get a message:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py:1328: UserWarning: findfont: Font family [u'serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
I am unsure how relevant this is, because the GUI plot and PDF show Times not DejaVu Sans for the tick labels?
I am using matplotlib 2.2.2. I added the lines you suggested and the output is 2.2.2
I can reproduce this issue on Mac OS 10.13.4, Python 3.6.5 :: Anaconda custom (64-bit), Matplotlib 2.2.2, pdfTeX 3.14159265-2.6-1.40.19 (TeX Live 2018)
Ah, maybe I can't reproduce because I can't find those font families:
/Users/jklymak/matplotlib/lib/matplotlib/font_manager.py:1220: UserWarning: findfont: Font family ['serif'] not found. Falling back to DejaVu Sans.
(prop.get_family(), self.defaultFamily[fontext]))
and
\Users/jklymak/matplotlib/lib/matplotlib/font_manager.py:1220: UserWarning: findfont: Font family ['times'] not found. Falling back to DejaVu Sans.
(prop.get_family(), self.defaultFamily[fontext]))
I tried this in a VM (Ubuntu 18.04) with --
Python 3.6.5 :: Anaconda custom (64-bit)
Matplotlib 2.2.2, pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian)
kpathsea version 6.2.3
with mpl.rcParams['font.serif'] = ['times'] I get the following warning (missing font families).
anaconda3/lib/python3.6/site-packages/matplotlib/font_manager.py:1328: UserWarning: findfont: Font family ['serif'] not found. Falling back to DejaVu Sans
with mpl.rcParams['font.serif'] = ['times new roman'] I do not get any warning.
In both cases, the pdf looks fine (with no streaks).
I have tried all the solutions above and they solve my problem if I plot and open them on my mac. But the problem persists when I open a file copied from a linux workstation. I've tried installing times.ttf (and make a copy to /anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/fonts/ttf) and also ~/Library/Fonts (and installing to the system), but the greek letters still appear as streaks in the copied file.
The greek letters look fine when viewed on the workstation.
I reproduce it with a figure produced on Debian 4.9.144-3.1 and matplotlib 3.1.0/python 3.7.3 installed from anaconda.
The figure shows correctly on the PDF Viewer opened by Jupyterlab in the web browser. However, when I save and open the file on the Mac with Preview.app, there is a streak. When I open it in Adobe Reader DC, I get an error message that it is impossible to extract the font "StandardSymL_Slant_167" and that some characters may not show properly. When the figure PDF in included in a LaTeX document, there are streaks.
I was also affected by this issue; somewhat embarrassingly, in a paper uploaded to arXiv.
The following Ghostscript command (from here) resolved it for me:
I was also affected by this issue; somewhat embarrassingly, in a paper uploaded to arXiv.
The following Ghostscript command (from here) resolved it for me:
Activity
jklymak commented on May 16, 2018
I can't reproduce MacOS 10.13.4 py 3.6, conda,
jklymak commented on May 16, 2018
test.pdf
jklymak commented on May 16, 2018
Oddly, your file is 10 bytes larger than mine. Otherwise I don't see a difference.
pdhall99 commented on May 16, 2018
Similar issue described in this comment: #9139 (comment)
jklymak commented on May 16, 2018
Agreed. Its strange I can't replicate it - I doubt the latex versions are the issue.
Did you clear your cache: (on my machine ~/.matplotlib/tex.cache) ? Maybe you had an old alpha in there causing grief?
You can also look in that directory and see the glyphs you are making... Maybe a clue there..
pdhall99 commented on May 17, 2018
Thanks. I have tried clearing the cache, but it didn't help.
I am not sure how to use the contents of tex.cache to find clues. Are you able to advise?
jklymak commented on May 17, 2018
The cache should have all the dvi and png files in it for all the text element s You can check that the alpha one looks correct
pdhall99 commented on May 17, 2018
The alpha dvi in tex.cache looks fine.
jklymak commented on May 17, 2018
What about the png?
pdhall99 commented on May 17, 2018
There is no png. Should there be?
jklymak commented on May 17, 2018
Oh, maybe not if you just use the PDF backend. I assume if you add a plt.show() the GUI plot looks OK?
Are you 100% sure you are using 2.2.2? i.e. can you add
to the above script?
Its strange that our almost-identical setups would behave differently. I suppose I could update TexLive just to be 100% certain...
pdhall99 commented on May 17, 2018
The GUI plot looks OK when I add plt.show(), but I get a message:
I am unsure how relevant this is, because the GUI plot and PDF show Times not DejaVu Sans for the tick labels?
I am using matplotlib 2.2.2. I added the lines you suggested and the output is 2.2.2
pdhall99 commented on May 18, 2018
I think the warning is because I only have Times.ttc on my machine, not Times.ttf. I don't think it is relevant to my issue.
pharshalp commented on May 19, 2018
I can reproduce this issue on Mac OS 10.13.4, Python 3.6.5 :: Anaconda custom (64-bit), Matplotlib 2.2.2, pdfTeX 3.14159265-2.6-1.40.19 (TeX Live 2018)
7 remaining items
jklymak commented on May 25, 2018
Ah, maybe I can't reproduce because I can't find those font families:
and
pharshalp commented on May 25, 2018
I tried this in a VM (Ubuntu 18.04) with --
Python 3.6.5 :: Anaconda custom (64-bit)
Matplotlib 2.2.2, pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian)
kpathsea version 6.2.3
anaconda3/lib/python3.6/site-packages/matplotlib/font_manager.py:1328: UserWarning: findfont: Font family ['serif'] not found. Falling back to DejaVu Sans
In both cases, the pdf looks fine (with no streaks).
jklymak commented on May 25, 2018
Thanks @pharshalp - times new roman works for me as well.
If anyone wants to figure out where there font is coming from:
pdhall99 commented on May 26, 2018
You can make a more minimal example that produces the error if you only change the following rcParams:
I find that changing
produces a PDF with all the text is Computer Modern, not Times. As does the following:
A minimal example that avoids the warning that matplotlib can't find Times.ttf but still has the problem displaying alpha:
lboogaard commented on Jun 25, 2018
Has there been any progress on this? I'm now running into this issue on osx after re-creating a figure that was fine before.
(Note that, as temporary workaround, one could save as a png.)
pdhall99 commented on Jun 25, 2018
If you have the newtxmath package then another workaround that works with PDF output is to add
astro313 commented on Apr 3, 2019
I have tried all the solutions above and they solve my problem if I plot and open them on my mac. But the problem persists when I open a file copied from a linux workstation. I've tried installing times.ttf (and make a copy to /anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/fonts/ttf) and also ~/Library/Fonts (and installing to the system), but the greek letters still appear as streaks in the copied file.
The greek letters look fine when viewed on the workstation.
jsalort commented on Jul 1, 2019
I reproduce it with a figure produced on Debian 4.9.144-3.1 and matplotlib 3.1.0/python 3.7.3 installed from anaconda.
The figure shows correctly on the PDF Viewer opened by Jupyterlab in the web browser. However, when I save and open the file on the Mac with Preview.app, there is a streak. When I open it in Adobe Reader DC, I get an error message that it is impossible to extract the font "StandardSymL_Slant_167" and that some characters may not show properly. When the figure PDF in included in a LaTeX document, there are streaks.
calvin-sykes commented on Dec 12, 2019
I was also affected by this issue; somewhat embarrassingly, in a paper uploaded to arXiv.
The following Ghostscript command (from here) resolved it for me:
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dEmbedAllFonts=true -sOutputFile=my_plot_embedded.pdf -f my_plot.pdf
I had to run this for each figure individually, running the command on the final LaTeX document did not work.
markushartmann commented on Jan 10, 2020
I reproduced also the error on Mac 10.12.6 mit python 2.7.17 und matplotlib 2.2.4.
Screenshot Adobe Reader
Screenshot Preview
spmulders commented on Mar 10, 2020
This actually works, thanks! On Windows, use gswin64c instead of gs, contained in the bin folder of Ghostscript.
jkseppan commented on Jul 28, 2020
I think this could be the same bug as #16087, which should be fixed on current master (by PR #18080).
QuLogic commented on Sep 9, 2020
I confirmed on the Mac mini that this is fixed by #18080.