I'm using matplotlib to create a histogram with bins fixed to be one pixel wide. I would like to get rid of the white space between these bins. This essentially means setting the x axis to be one pixel per value on the axis (i.e.: there should 100 bins per 100 pixels on the x axis).
This is the code I am currently using:
def gen_histogram(data, binsize, title=None, minimum=None, maximum=None):
import matplotlib.pyplot as plt
plt.hold(False)
if minimum is None:
minimum = 0
if maximum is None:
maximum = 18207
(n, bins, patches) = plt.hist(data, bins=numpy.arange(minimum, maximum + binsize, binsize), width=1)
plt.xlabel('z')
plt.ylabel('% of total')
plt.title(title, loc='left', fontsize=11)
So, I want all the bins to be touching each other while remaining one pixel in width. Here is a picture of my current output,
.