#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ ENGG1811 Lecture Week 06 Use the plot() function in the matplotlib to show that functions can be made flexible """ # %% Part 1: default behaviour plot() import matplotlib.pyplot as plt data_x = [1,2,3,4] data_y = [1,4,2,3] plt.plot(data_x,data_y) # Default plt.show() # to display the graph # %% Part 2: plot() has many customisable options data_x = [1,2,3,4] data_y_0 = [1,4,2,3] data_y_1 = [4,1,3,0] data_y_2 = [5,3,1,2] data_y_3 = [2,5,6,6] plt.figure() plt.plot(data_x,data_y_0) plt.plot(data_x,data_y_1,color='red') plt.plot(data_x,data_y_2, linestyle='dashed',color='magenta', label='Data 2') plt.plot(data_x,data_y_3,label='Data 3', color='blue',linestyle='dotted',linewidth=5, marker='o',markerfacecolor='green',markersize=10) plt.legend() plt.show() # Note: Some of the above lines can be written as: # Line 30: plt.plot(data_x,data_y_1,'r') # Line 31: plt.plot(data_x,data_y_2,'m--',label='Data 2')