#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ ENGG1811 Lecture Week 02 Demonstration on how to use plot """ import matplotlib.pyplot as plt load = [0, 1650, 3400, 5200, 6850, 7750, 8650, 9300, 10100, 10400] length = [2.000, 2.002, 2.004, 2.006, 2.008, 2.010, 2.020, 2.040, 2.080, 2.120] fig1 = plt.figure() # create a new figure plt.plot(load,length,'x') # Plot each point with a cross # plt.plot(load,length) # plot(data in x-axis, data in y-axis) # The above command will join the points with line plt.xlabel('load [lbf]') # label for x-axis plt.ylabel('length [inches]') # label for y-axis plt.title('Tensile strength test') # title of the graph # plt.grid() # display the grid plt.show() # to display the graph fig1.savefig('tensil_test.png') # save the graph as a PNG file fig1.savefig('tensil_test.pdf') # save the graph as a PDF file