However, the datalim seems so implicitly include zero.

> For example, if min(y_values) is 3, I still see the point

> of origin. How can I avoid this behaviour?

We're just doing what we're told here

Your first plot call is

y_values = total_number_values * [0.0]

line, = plot(x_values, y_values)

So zero is *explicitly* included. The datalim remember the history of

objects have have been added. If you want them to ignore their

history, call

ax.dataLim.update_numerix(x_values, y_values, True)

The third argument if True will cause the datalim to update it's

bounds ignoring history. If False, it will update the bounds

including it's past history.

Note that in the original example you posted

for i in range(2*cycles):

voltages = number_of_values * [i % 2 + 3]

y_values[i * number_of_values : (i+1) * number_of_values] = \

voltages

line.set_ydata(y_values)

print min(y_values), max(y_values)

ax.dataLim.update_numerix(x_values, y_values, True)

min(y_values) == 0

JDH