speedup figure rendering removal of .startswith() calls and use generato...

speedup figure rendering removal of .startswith() calls and use generators instead of for loops

Please see the email thread:
    [Matplotlib-users] mpl-1.2.1: Speedup code by removing .startswith() calls and some for loops
for more details.