pythonmatplotlib模块绘制基本图形的方法-创新互联
这篇文章主要讲解了python matplotlib模块绘制基本图形的方法,内容清晰明了,对此有兴趣的小伙伴可以学习一下,相信大家阅读完之后会有帮助。
matplotlib模块是python中一个强大的绘图模块
安装 pip install matplotlib
首先我们来画一个简单的图来感受它的神奇
import numpy as np import matplotlib.pyplot as plt import matplotlib zhfont1=matplotlib.font_manager.FontProperties(fname="SimHei.ttf") #-------设置字体,这个可以事先下载https://www.fontpalace.com/font-details/SimHei/
x=np.arange(1,11,1) #-------从数字1到11,步长为1 y=2 * x +5
plt.title("我是标题",fontproperties=zhfont1) #--------设置标题 plt.xlabel("x坐标标题",fontproperties=zhfont1) #---------设置x坐标名称 plt.ylabel("y坐标标题",fontproperties=zhfont1) #---------设置y坐标名称 plt.plot(x,y) #---------开始绘制 plt.plot(x,y,":r") 表示使用虚线红颜色绘制
网页标题:pythonmatplotlib模块绘制基本图形的方法-创新互联
分享URL:http://tyjierui.cn/article/dcccco.html