matplotlib/matplotlib — pull request #854 by mdboom (2013-05-28 20:33:33+00:00)
Title: Bug in Axes.relim when the first line is y_isdata=False and possible fix

You can reproduce the bug with:

```python
from matplotlib import pyplot
ax = pyplot.axes()
ax.axvline(0.5)
ax.plot([-0.1, 0, 0.2, 0.1])
ax.relim()
ax.autoscale()
(ymin, ymax) = ax.get_ylim()
print ymin, ymax
pyplot.show()
```

Printed ylim is `-0.2 1.0` where the upper bound should be something like 0.25. You will see that there is big space between data line and the top bound.

To workaround this problem, I defined the following functions:

```python
def _update_line_limits(self, line, updatex=True, updatey=True):
p = line.get_path()
if p.vertices.size > 0:
self.dataLim.update_from_path(p, self.ignore_existing_data_limits,
updatex=updatex and line.x_isdata,
updatey=updatey and line.y_isdata)
if (updatex and line.x_isdata) or (updatey and line.y_isdata):
self.ignore_existing_data_limits = False

def relim(self):
self.dataLim.ignore(True)
for (udatex, updatey) in [[True, False], [False, True]]:
self.ignore_existing_data_limits = True
for line in self.lines:
_update_line_limits(self, line, udatex, updatey)

for p in self.patches:
self._update_patch_limits(p)
```

If you call `relim(ax)` instead of `ax.relim()`, printed ylim is `-0.1 0.25`. I just simply separate the update of the line limits for x and y axis. I think you can simply replace the two functions with Axes.relim and Ax._update_line_limits.

I have currently have no time for preparing executable development version of matplotlib and its test environment. I will send a pull request at some point when I am ready, but if somebody can "pull" the snippet above and test it, please do that.