#plt is alias for the longer name 'matplotlib.pyplot' import matplotlib.pyplot as plt table_data = [["Zane",7], ["Bob",10], ["Jim",37], ["Stacey",21] ] # Prepare data for plotting names = [] values = [] #'row' successively contains each row from the above list for row in table_data: name = row[0] #Extracts Col 0 values with each iteration (Zane,Bone,Jim,Stacey) try: # row[1:] extracts from index 1 onward in the row i.e. 7,10,37,21 numeric_values = [float(val) for val in row[1:]] #total = sum(numeric_values) names.append(name) total = numeric_values values.append(total) except ValueError: print(numeric_values,"is non-numeric") continue #Uncomment below if you wish to see the valeus from Col 0 and Col 1 #stored in names,values (respectively) # print(names,values) # Plot scatter graph plt.figure(figsize=(8, 6)) #size in inches plt.scatter(names, values, color="blue", label="ScatterJT") #legend/data pt color, legend text plt.plot(names, values, color="orange", label="LineJT", marker="X") #color: legend text, line plt.title("Total Values by Name") plt.xlabel("Name") plt.ylabel("Total Value") plt.legend() #Displays a legend with the text "ScatterJT", "LineJT" plt.grid(True) #Adds lines to the horizontal & vertical grids plt.tight_layout() #Adjust spacing so text doesn't overlap or get cut off plt.show()