1import matplotlib.pyplot as plt
2fig = plt.figure(1) #identifies the figure
3plt.title("Y vs X", fontsize='16') #title
4plt.plot([1, 2, 3, 4], [6,2,8,4]) #plot the points
5plt.xlabel("X",fontsize='13') #adds a label in the x axis
6plt.ylabel("Y",fontsize='13') #adds a label in the y axis
7plt.legend(('YvsX'),loc='best') #creates a legend to identify the plot
8plt.savefig('Y_X.png') #saves the figure in the present directory
9plt.grid() #shows a grid under the plot
10plt.show()
1import matplotlib.pyplot as plt
2plt.plot([1, 2, 3, 4], [1, 4, 9, 16])
3plt.show()
1import matplotlib.pyplot as plt
2plt.plot([1, 2, 3, 4])
3plt.ylabel('some numbers')
4plt.show()
5
1import matplotlib.pyplot as plt
2%matplotlib inline
3plt.plot(data)
4#this is not nessisary but makes your plot more readable
5plt.ylabel('y axis means ...')
6plt.xlabel('x axis means ...')
1plot([x], y, [fmt], *, data=None, **kwargs)
2plot([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)
3