一些答案开始到达那里。。。但是,这些点已连接到绘图上的一条线中。我们如何绘制点?
import matplotlib.pyplot as pltimport numpy as npdef f(x): if(x == 2): return 0 else: return 1x = np.arange(0., 5., 0.2)y = []for i in range(len(x)): y.append(f(x[i]))print xprint yplt.plot(x,y,c='red', ls='', ms=5, marker='.')ax = plt.gca()ax.set_ylim([-1, 2])plt.show()



