ubuntu2004
# Make the matplotlib and matplotlib.pyplot modules available1import matplotlib2matplotlib.use("Agg")3import matplotlib.pyplot as plt45# Initialize a list for the x values and the y values6x_values = []7y_values = []89done = False1011# Read input from the user until they enter an empty string12while not done:13pair = raw_input('Enter an x,y pair to be plotted: ')1415#Test to see if the user entered the empty string, if not16if pair != '':17# Input in the form x,y. Break this up into an x value and a y value18values = pair.split(",")19# Add the x value to a list of x values20x_values.append(float(values[0]))21# Add the y value to a list of y values22y_values.append(float(values[1]))23else:24done = True2526print 'x values are', x_values, 'and y_values are', y_values2728# Create a plot from the lists of x and y values29plt.plot(x_values, y_values)3031# Save the plot into a .png file for later viewing32plt.savefig('scatter.png')333435