# coding: utf-8 # In[120]: import matplotlib.pyplot as plt # In[121]: import numpy as np # In[122]: x = np.arange(10) y = x**2 yy = x**3 # In[124]: plt.plot(x,y) # In[125]: plt.plot(x,y,'o') # In[126]: # multiple lines in a plot plt.plot(x,y,'o') plt.plot(x, yy, 'g') # In[127]: # aggiungiamo anche alcuni dettagli plt.grid() plt.xlabel('x / unit') plt.ylabel('y / unit') plt.title('First plot') plt.plot(x,y,'o') plt.plot(x, yy, 'g') # save the plot plt.savefig('plot.png', dpi=250) #### Object Oriented interface # In[135]: fig = plt.figure() #we need to add one or more subplot ax1 = fig.add_subplot(221) ax2 = fig.add_subplot(222) ax3 = fig.add_subplot(223) # let's fill the subplot ax1.plot(x,y) ax2.plot(x,y**2, linestyle='--') # dashed line l, = ax3.plot(x,y**4, 'ko--') # markers l.set_label('third') ax3.legend() plt.show() # or just show() # In[115]: x # In[117]: