每日学习笔记7-16

python matplotlib库绘制折线图 

实现title中文编码

引入字体更改 from matplotlib.font_manager import FontProperties

myfont  = FontProperties(fname = "hello.ttc")

#hello.ttc是我下载的ttc字体文件

plt.title("你好",FontProperties = myfont,fontsize = "14")

plt.xlabel(xlabel,FontProperties = myfont, fontsize = "14")

#完成了title xlabel ylabel汉字编码的实现

实现折线图的比例和大小的调整

plt.figure(figsize = (10,5))

#(10,5)配合后面的dpi设计相乘就是折线图图片的分辨率

plt.savefig("hello.png",dpi = 300)

猜你喜欢

转载自www.cnblogs.com/newliu/p/9321156.html