Everything in green above this point can be accomplished with
```python
y = np.ravel(y)
xmin = np.ravel(xmin)
xmax = np.ravel(xmax)
```
or that could even be packed into a single line with map or a list comprehension.  After doing this, there is no need to check the number of dimensions.
However, it looks like you are leaving out the critical resize operation.  Everything needed could be done like this:
```python
y = np.ravel(y)
xmin = np.resize(xmin, y.shape)
xmax = np.resize(xmax, y.shape)
```
Now, none of the checks in the blocks below are needed, either.
Note: unlike most plotting methods, this one does not support masked arrays; but it never did, so the simplification suggested here is not hurting anything.