Q:

How to disable auto zoom in a matplotlib bar chart?

I have a data, which contains values for each day of January:
self.y_data:  [0, 0, -4, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

matplotlib bar chart uses this self.y_data to set y values for each day. But I get the following chart:

Why only 4 values are shown in the graph? How do I display all 31 values?

A:

It seems that the x axis range is not set to include the points where the data is zero.  One workaround is simply to explicitly set the x limit according to the data.
import matplotlib.pyplot as plt 

y  = [0, 0, -4, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0]
x = xrange(len(y))

fig, ax = plt.subplots(1, 2)
# show with default limits
h0 = ax[0].bar(x, y)
# same data, but explicitly set x range
h1 = ax[1].bar(x, y)
ax[1].set_xlim(x[0], x[-1]+1)

plt.show()

Note: this matplotlib forum post also describes a similar issue.
(I had to guess where your x values come from but the principle is shown) 

