Our second example will demonstrate to you how to create multiple graphics panels and plot a representation on each of them. We will also try to personalize the drawn curves by using different colors, sizes, and styles. Here is the example:
In: import matplotlib.pyplot as plt # defines 1 row 2 column panel, activates figure 1 plt.subplot(1,2,1) plt.plot(x,y_cos,'r--') # adds a title plt.title('cos') # defines 1 row 2 column panel, activates figure 2 plt.subplot(1,2,2) plt.plot(x,y_sin,'b-') plt.title('sin') plt.show()
The plot displays the cosine and sine curves on two distinct graphic panels: