作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我试图在 matplotlib
中绘制一个简单的抛物线,但我对如何在抛物线上绘制点感到困惑。到目前为止,这就是我所拥有的:
import matplotlib.pyplot as plt
a=[]
b=[]
y=0
x=-50
while x in range(-50,50,1):
y=x^2+2*x+2
a=[x]
b=[y]
fig= plt.figure()
axes=fig.add_subplot(111)
axes.plot(a,b)
plt.show()
x= x+1
最佳答案
应该这样做:
import matplotlib.pyplot as plt
import numpy as np
# create 1000 equally spaced points between -10 and 10
x = np.linspace(-10, 10, 1000)
# calculate the y value for each element of the x vector
y = x**2 + 2*x + 2
fig, ax = plt.subplots()
ax.plot(x, y)
关于python - 在 Python 中使用 Matplotlib 绘制抛物线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30553585/
我需要让 Excel 将大约 5 个点绘制成一条曲线。如果这些点没有完美排列,我正在寻找的是所有点的平均值。我对 Excel 上的绘图不是很熟悉,所以很可能我忽略了一些选项来获得我想要实现的目标。 这
我想做类似this的事情,但要相反-以便摄像机在外面并指向内部。让我们从抽象开始,并进行具体说明: 1)是否有任何工具可以帮我做到这一点?我可以使用现有软件多近的距离? 2)说最近的工具是像OpenC
我使用 JFreeChart 写了一个简单的抛物线图。 package parabolademo; import java.awt.geom.Point2D; import java.awt.geom
我得到了三个点,需要绘制一条平滑的 3D 抛物线。问题是曲线起伏不定,而且有一些奇怪的凹痕 这是我的代码... func drawJump(jump: Jump){ let halfDista
我目前正在开发一款2D Android 游戏, 在这个游戏中,一个ViewObject(Bitmap)在Parabola Path上在屏幕上移动,就像在这个图像中一样,但是这个路径是静态的,静态路径正
我是一名优秀的程序员,十分优秀!