try catch on matplotlib