Step function plots#

sage.plot.step.plot_step_function(v, vertical_lines=True, **kwds)#

Return the line graphics object that gives the plot of the step function \(f\) defined by the list \(v\) of pairs \((a,b)\). Here if \((a,b)\) is in \(v\), then \(f(a) = b\). The user does not have to worry about sorting the input list \(v\).

INPUT:

  • v – list of pairs (a,b)

  • vertical_lines – bool (default: True) if True, draw vertical risers at each step of this step function. Technically these vertical lines are not part of the graph of this function, but they look very nice in the plot, so we include them by default

EXAMPLES:

We plot the prime counting function:

sage: plot_step_function([(i, prime_pi(i)) for i in range(20)])
Graphics object consisting of 1 graphics primitive
../../_images/step-1.svg
sage: plot_step_function([(i, sin(i)) for i in range(5, 20)])
Graphics object consisting of 1 graphics primitive
../../_images/step-2.svg

We pass in many options and get something that looks like “Space Invaders”:

sage: v = [(i, sin(i)) for i in range(5, 20)]
sage: plot_step_function(v, vertical_lines=False, thickness=30,
....:                    rgbcolor='purple', axes=False)
Graphics object consisting of 14 graphics primitives
../../_images/step-3.svg