for_step#

Hist1d.for_step(extent_to=None)[source]#

Return arrays appropriate for plotting with plt.step.

By default, plt.step needs the right edges of a bin and the corresponding bin value. See the where keyword argument.

Attention

Don’t use anything else but where="pre" (which is the default) in plt.step. Otherwise the histogram will be shifted.

Parameters:
extent_tofloat, optional

Extent the edges to this value (useful if the resulting plot should start at, e.g., zero).

Returns:
right_edgesndarray

Right edges, that is, Hist1d.edges[1:].

valuesndarray

Bin values, that is, Hist1d.values.

See also

for_bar
for_plot

Examples

Plot hist: Hist1d:

plt.step(*hist.for_step())

If where != "pre", the resulting histogram will be shifted!:

plt.step(*hist.for_step(), where="mid") # this will have shifted bins