python绘图设置新罗马字体_更改matplotlib中的字体
所以我已經嘗試了很多我能在stackoverflow上找到的東西(還有其他任何google會引導我的地方);我就是不能改變該死的字體!
以下是我迄今為止所做嘗試的非詳盡列表:import matplotlib.pyplot as plt
csfont = {'fontname':'Times New Roman'}
x = [1,2,3]
y = x
plt.plot(x,y)
plt.title('Please be Times >__
plt.show()
提供此錯誤日志:>>> (executing file "")
Note on using QApplication.exec_():
The GUI event loop is already running in the pyzo kernel, and exec_()
does not block. In most cases your app should run fine without the need
for modifications. For clarity, this is what the pyzo kernel does:
- Prevent deletion of objects in the local scope of functions leading to exec_()
- Prevent system exit right after the exec_() call
/home/antoine/miniconda3/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['Times New Roman'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
>>>import matplotlib.pyplot as plt
plt.rcParams["font.family"] = "Times New Roman"
x = [1,2,3]
y = x
plt.plot(x,y)
plt.title('Please be Times >__
plt.show()
沒有顯示錯誤;但這不是時間。。。
對我來說,第一次嘗試給出錯誤日志也有點困難,因為做this answer建議的事情表明,Times New Roman確實是一種我應該能夠使用的字體:>>> set([f.name for f in matplotlib.font_manager.fontManager.afmlist])
{'Courier', 'Times', 'URW Bookman L', 'Nimbus Mono L', 'ITC Bookman', 'ZapfDingbats', 'Century Schoolbook L', 'New Century Schoolbook', 'Helvetica', 'Standard Symbols L', 'Utopia', 'Palatino', 'URW Gothic L', 'Courier 10 Pitch', 'Symbol', 'Computer Modern', 'Bitstream Charter', 'ITC Avant Garde Gothic', 'Nimbus Roman No9 L', 'ITC Zapf Chancery', 'ITC Zapf Dingbats', 'URW Chancery L', 'Nimbus Sans L', 'Dingbats', 'URW Palladio L'}
所以。。。我還能試什么?
總結
以上是生活随笔為你收集整理的python绘图设置新罗马字体_更改matplotlib中的字体的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在Visual Studio中对Epic
- 下一篇: 《中国近代史纲要》考试过关?Python