Python3.7里怎么画ln(x)图像

百香果不酸鸭 2018-09-09 11:37:21
写y=math.log(x,math.e)老是出现错误
...全文
3779 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
红色部分应该是用np.log()吧,math.log不支持array
引用 4 楼 百香果不酸鸭 的回复:
[quote=引用 3 楼 pengnidaye的回复:][quote=引用 1 楼 chuifengde的回复:]怎么画的,什么错误 小乌龟绘图,没有问题。
import math
import turtle

mTurtle=turtle.Turtle()
for x in range(1,1000):
    y=math.log(x, math.e)
    mTurtle.goto(x,y*10)
    mTurtle.dot(1)
这样画的,这个错误。[/quote] import numpy as np import math import matplotlib as plt x=np.linspace(0,1,50) y=math.log(x,math.e) plt.plot(x,y) plot.show[/quote]
chuifengde 2018-09-10
  • 打赏
  • 举报
回复
怎么画的,什么错误
小乌龟绘图,没有问题。
import math
import turtle

mTurtle=turtle.Turtle()
for x in range(1,1000):
y=math.log(x, math.e)
mTurtle.goto(x,y*10)
mTurtle.dot(1)
百香果不酸鸭 2018-09-10
  • 打赏
  • 举报
回复
引用 3 楼 pengnidaye的回复:
[quote=引用 1 楼 chuifengde的回复:]怎么画的,什么错误
小乌龟绘图,没有问题。
import math
import turtle

mTurtle=turtle.Turtle()
for x in range(1,1000):
y=math.log(x, math.e)
mTurtle.goto(x,y*10)
mTurtle.dot(1)
这样画的,这个错误。[/quote] import numpy as np import math import matplotlib as plt x=np.linspace(0,1,50) y=math.log(x,math.e) plt.plot(x,y) plot.show
百香果不酸鸭 2018-09-10
  • 打赏
  • 举报
回复
我用的matplotlib画的,不知道这个错误怎么解决。
百香果不酸鸭 2018-09-10
  • 打赏
  • 举报
回复
引用 1 楼 chuifengde的回复:
怎么画的,什么错误
小乌龟绘图,没有问题。
import math
import turtle

mTurtle=turtle.Turtle()
for x in range(1,1000):
y=math.log(x, math.e)
mTurtle.goto(x,y*10)
mTurtle.dot(1)
这样画的,这个错误。

37,742

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧