I am trying to get a histogram with already binned data. I have been trying to use bar() for this, but I can't seem to figure out how to make it a stepped histogram like this one from the examples, instead of a filled histogram.

for N bars, bins is an numpy.ndarray of N+1 values, being the edges for each bar. They twin the values for each bar (this is what fraxel is doing with np.ravel below) and shift the datapoints half a bar left to center them

x[0::2], x[1::2] = bins, bins
x -= 0.5*(bins[1]-bins[0])

set the height of each bar, twinned but offset by one (relative to the x values) to produce the step effect

The simplest solution is to convert your binned dataset to an un-binned, weighted dataset (with number of elements == number of bins). The unbinned dataset would consist of data values equal to the bin centres and weights equal to the values in each bin. For example let's say that your binned data is,

binedges = [0.0, 1.0, 2.0, 3.0]
ybinned = [11., 22., 33.]

The corresponding weighted dataset would be,

y = [0.5, 1.5, 2.5]
weights = [11., 22., 33.]

Note that the choice to use the bin centre is arbitrary, you could use any point within a bin. Once you have generated the un-binned dataset then you can use the normal matplotlib histogram plotting (i.e. Axes.hist).

The 20 and 300 that are added are my binsize and ending value respectively, and need to be adjusted if anyone wants to use this. x_input and y_input are the returning values from np.histogram. My resulting plot (in blue the contour, plotted with above function. In red, the barplot of the same data):