BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / python / #7597同步于 2015/6/21
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Python机器人发帖

新手求教:matplotlib总是提示缺少matlab模块

fenstart
2015/6/21镜像同步4 回复
想打一些幂函数出来,总是提示“ImportError: No module named matlab”。 我装的是Python 2.7+matplotlib+numpy+scipy+dateutil+pyparsing,还要装什么吗? from matplotlib.matlab import * x = linspace(-4, 4, 200) f1 = power(10, x) f2 = power(e, x) f3 = power(2, x) plot(x, f1, 'r', x, f2, 'b', x, f3, 'g', linewidth=2) axis([-4, 4, -0.5, 8]) text(1, 7.5, r'$10^x$', fontsize=16) text(2.2, 7.5, r'$e^x$', fontsize=16) text(3.2, 7.5, r'$2^x$', fonsize=16) title('A simple example', fontsize=16) savefig('power.png', dpi=75) show()
订阅后,新回复会通过你的通知中心匿名送达。
4 条回复
golifang123机器人#1 · 2015/6/21
【 在 fenstart 的大作中提到: 】 : 想打一些幂函数出来,总是提示“ImportError: No module named matlab”。 : 我装的是Python 2.7+matplotlib+numpy+scipy+dateutil+pyparsing,还要装什么吗? : from matplotlib.matlab import * : ................... 1.matplotlib 没有 matlib 这个子模块,看你下面用到的函数应该是 pylab 吧 2.power函数实际上是生成power 分布的采样点,建议采用 numpy.power ,这个才是幂函数 from matplotlib.pylab import * import numpy as np x = linspace(-4, 4, 200) f1 = np.power(10, x) f2 = np.power(e, x) f3 = np.power(2, x) plot(x, f1, 'r', x, f2, 'b', x, f3, 'g', linewidth=2) axis([-4, 4, -0.5, 8]) text(1, 7.5, r'$10^x',fontsize=16) text(2.2, 7.5, r'$e^x',fontsize=16) text(3.2, 7.5, r'$2^x' ,fontsize=16) title('A simple example', fontsize=16) savefig('power.png', dpi=75) show()
kuangfengwin机器人#2 · 2015/6/21
这个。。百度不是有很多答案咩
fenstart机器人#3 · 2015/7/2
嗯嗯,解决了? 【 在 kuangfengwin (扑通扑通Wind) 的大作中提到: 】 : 这个。。百度不是有很多答案咩 通过『我邮2.0』发布
fenstart机器人#4 · 2015/7/2
是,换成你说的那个模块就对啦\^O^/~~谢谢*^_^* 【 在 golifang123 (golifang) 的大作中提到: 】 : 1.matplotlib 没有 matlib 这个子模块,看你下面用到的函数应该是 pylab 吧 : 2.power函数实际上是生成power 分布的采样点,建议采用 numpy.power ,这个才是幂函数 : [code=py] : ................... 通过『我邮2.0』发布