首页 > 代码库 > 使用matplotlib在python中画图
使用matplotlib在python中画图
一、安装
此处以Ubuntu12.04为例:
$ sudo apt-get install ipython python-matplotlib python-numpy
二、简单实例
>>> plt.figure(1) # 创建图表1<matplotlib.figure.Figure object at 0x26fda10>>>> plt.figure(2) # 创建图表2<matplotlib.figure.Figure object at 0x2a5f610>>>> ax1 = plt.subplot(211) # 在图表2中创建子图1>>> ax2 = plt.subplot(212) # 在图表2中创建子图2>>> x = np.linspace(0, 3, 100)>>> plt.figure(1) # 选择图表1<matplotlib.figure.Figure object at 0x26fda10>>>> plt.plot(x, np.exp(x/3))[<matplotlib.lines.Line2D object at 0x36383d0>]>>> plt.sca(ax1) # 选择图表2的子图1>>> plt.plot(x, np.sin(x))[<matplotlib.lines.Line2D object at 0x3638890>]>>> plt.sca(ax2) # 选择图表2的子图2>>> plt.plot(x, np.sin(2*x))[<matplotlib.lines.Line2D object at 0x3638dd0>]>>> plt.show()
三、画MDCT正反变化图
四、参考
http://www.cnblogs.com/wei-li/archive/2012/05/23/2506940.html
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。