move plotting stuff out of __main__