python xy不在第一维度_ValueError:x和y必须具有相同的第一个维度ipython 3.5

新手在ipython中使用matplotlib绘图时遇到错误:ValueError: x and y must have same first dimension。代码中定义了函数derivative和derivative_estimate,并尝试绘制实际导数与估计导数的对比图,但调用plot函数时出现了上述错误。
摘要由CSDN通过智能技术生成

我是ipython的新手 . 我在ipython中有这段代码

def derivative(x):

return 3*(x^2)

derivative_estimate = lambda x: difference_quotient(cube, x, h=0.00001)

x = range(-10, 10)

import matplotlib.pyplot as plt

plt.title("Actual Derivatives vs Estimates")

x = range(-10,10)

plt.plot(x, map(derivative, x), 'rx', label = 'Actual') # red x

plt.plot(x, map(derivative_estimate, x), 'b+', label = 'Estimate') # blue +

plt.show()

当我尝试运行它时,它会向我显示这些错误

ValueError Traceback (most recent call last)

in ()

6 plt.title("Actual Derivatives vs Estimates")

7 x = range(-10,10)

----> 8 plt.plot(x, map(derivative, x), 'rx') # red x

9 plt.plot(x, map(derivative_estimate, x), 'b+') # blue +

10 plt.show()

C:\Users\

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值