Omit joining lines in matplotlib plot e.g. y = tan(x)

前端 未结 4 1071
囚心锁ツ
囚心锁ツ 2020-12-04 01:48

I have the graph y = tan(x) and I want to remove the vertical lines (see below).

Here is my code:

import numpy as np
import matplotlib.p         


        
4条回答
  •  旧时难觅i
    2020-12-04 02:47

    Use the definition of tan, sin/cos. The vertical asymptotes will happen when cos = 0, so write a conditional statement such as: if cos(x) != 0: plt.plot(x, np.tan(x))

提交回复
热议问题