TIPE-OperationValkyrie-Absobel/fig/replaced_by_d3/step.py

24 lines
417 B
Python

"""
step
~~~~~~~
Plots a graph of a step function."""
import numpy
import matplotlib.pyplot as plt
z = numpy.arange(-5, 5, .02)
step_fn = numpy.vectorize(lambda z: 1.0 if z >= 0.0 else 0.0)
step = step_fn(z)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(z, step)
ax.set_ylim([-0.5, 1.5])
ax.set_xlim([-5,5])
ax.grid(True)
ax.set_xlabel('z')
ax.set_title('step function')
plt.show()