Python-matplotlib用infiniite f(x)值绘制
我正在尝试在matplotlib中绘制棕褐色函数。 当插入的值为pi/2
时,tan
函数将变为无穷大。问题在于我不知道如何处理matplotlib中的无限数字,或者又是无限的小范围来绘制它。问题之一是降低的行,试图连接上一个绘制顶部的点,而第一个pi/2
import matplotlib.pyplot as plt
import numpy
x_values = numpy.linspace(-5,5,num=1000)
y_values = numpy.tan(x_values)
plt.plot(x_values, y_values)
plt.show()
这是输出:
i.sstatic.net/hg2st.png“ rel =“ nofollow noreferrer 是因为此功能获得1000点绘制的点,而不是无限点,但它并没有创建我想要的图像,我想要像图形计算器会产生的图像一样。 我能做些什么?
I am trying to graph the tan function in matplotlib.
The tan
function goes to infinity when the value inserted is pi/2
. The problem is that I dont know how to deal with infinite numbers in Matplotlib or in turn, infinitly small ranges to be able to plot it. One of the problems is the line that goes down, to try to connect the last dot drawn up top, with the first after pi/2
import matplotlib.pyplot as plt
import numpy
x_values = numpy.linspace(-5,5,num=1000)
y_values = numpy.tan(x_values)
plt.plot(x_values, y_values)
plt.show()
This is the output:
This is because this function gets 1000 points to plot, not infinite points, but it doesn't create the image that I want, I want an image like the one that a graphic calculator would produce.
What can I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如何绘制不连续的函数
渐变函数的不连续点
- codeshift> shift
shift - 距离 - 距离从数据到左How to plot a discontinuous function
asymptotes
- discontinuity points of the tangent functioneps
- a radius of the excluded neighborhood around the discontinuity pointsshift
- distance from data to nearest breakpoints on the left