如何通过python中的drawparallels将标签字体设置为“Time New Roman”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40734672/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set the label Fonts as "Time New Roman" by drawparallels in python
提问by Wang Tao
I have draw a map with latitudes labelled but I want to set the fonts as "Times New Roman". How to make it possible?
我画了一张标有纬度的地图,但我想将字体设置为“Times New Roman”。如何使它成为可能?
m.drawparallels(parallels,labels=[1,0,0,0],fontsize=12)
m.drawparallels(parallels,labels=[1,0,0,0],fontsize=12)
回答by Wasi Ahmad
You need to set font family using pyplot
of matplotlib
.
您需要使用pyplot
of设置字体系列matplotlib
。
import matplotlib.pyplot as plt
csfont = {'fontname':'Times New Roman'}
// write your code related to basemap here
plt.title('title',**csfont)
plt.show()
You can also use the following to change font globally.
您还可以使用以下内容全局更改字体。
import matplotlib.pyplot as plt
plt.rcParams["font.family"] = "Times New Roman"