Fixed matplotlib loop