美文网首页
Python-matplotlib (简介)

Python-matplotlib (简介)

作者: ZeroDesigner | 来源:发表于2019-07-06 20:51 被阅读0次
Matplotlib

这是一个用来绘图的包,这里进行一下介绍以及实例演练,可以作为一专业的模块来学习。
Matplotlib是一个Python 2D绘图库,可以生成各种硬拷贝格式和跨平台交互式环境的出版物质量数据。Matplotlib可用于Python脚本,Python和IPython shell,Jupyter笔记本,Web应用程序服务器和四个图形用户界面工具包。

安装以及测试
#安装
conda install -c conda-forge matplotlib
#显示可视化界面的IDE
ipython qtconsole
#导入包
import matplotlib.pyplot as plt
import numpy as np
#绘制sin与cos曲线
#x区间为0到10,100个数
x = np.linspace(0, 10, 100)
#绘制
plt.plot(x, np.sin(x))
plt.plot(x, np.cos(x))
#展示
plt.show()
sin(x)为实线,cos(x)为虚线
x = np.linspace(0, 10, 100)

fig = plt.figure()
plt.plot(x, np.sin(x), '-')
plt.plot(x, np.cos(x), '--')
#保存图像
fig.savefig('my_figure.png')
#展示保存的图像
from IPython.display import Image
Image('my_figure.png')

相关文章

网友评论

      本文标题:Python-matplotlib (简介)

      本文链接:https://www.haomeiwen.com/subject/ebumhctx.html