is_scalar and legend (was: color argument to collections)

John Hunter <jdhunter@...5...> writes:

I just looked in cbook and we did indeed have an is_scalar function
but it looked broken so I replaced it with

def is_scalar(obj):
    try: obj+1
    except TypeError: return False
    else: return True

This seems to have broken axes.legend(), which for some reason calls
flatten(handles), where handles contains instances of classes like
lines.Line2D, which fail the new is_scalar test. I don't see why the
list should need flattening, except if the user passes in a non-flat