Plot function modified to create subplots