Is there a way to optimize this code for subplots in python

welcome to shbcf.ru