Followers

Monday, 1 May 2017

matplotlib: how to access internal cm font?

Source: stackoverflow.com --- Sunday, April 30, 2017
I am using python2.7 on Windows 10, with Anaconda, and having some issue configuring font. First of all, I am aware that this issue is quickly resolved if I install required fonts. But I want to know whether I can resolve this WITHOUT installing any new font. I have this simple code for plotting. import matplotlib as mpl mpl.rcParams['font.family']='serif' mpl.rcParams['mathtext.fontset']='cm' import matplotlib.pyplot as plt plt.plot([1,2,3],[4,3,4]) plt.text(1.5,4,'Hello!') plt.show() and it works perfectly. Since Computer Modern font is not installed on my computer(bizarre considering I installed TeXLive, but that's irrelevant.), matplotlib must have it internally. Now, I want my serif font to be computer modern also. I thought adding mpl.rcParams['font.serif']=['cm'] between mpl.rcParams[] lines would work. Instead, it gave this warning C:\ProgramData\Anaconda2\lib\site-packages\matplotlib\font_manager.py:1297: UserWarning: findfont: Font family [u'serif'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) This is quite confusing. I don't have computer modern font installed on my computer, but since setting mathtext.fontset as cm worked fine, I think there should be some way to allocate that internal font for font.serif . What would be a solution for this? ...



from Windows http://ift.tt/2qumydJ

No comments:

Post a Comment