Take a list of coordinates and plot them on a graph
Question: Right now I have a list of coordinates that are in the following format:

    
    
    (1,12),(2,3),(3,9)....
    

All the coordinates are in brackets as above, and the format is exactly the
same for the rest of the string (the list is in string format). The x-values
of the coordinates increase by one throughout the string (and could continue
on to even 100000. The y-values are random and could range from 1 to 2048 or
even higher numbers. I want to find a way to take that string (which is a list
of coordinates in the above format) and turn it into a picture or virtual
graph, with each point plotted on it. I am currently using Python 2.7 in
visual studio, but am open to using other programs, as the string itself is
stored in a .txt file in the above format.

Once that is done, I'd like to be able to take that graph and using only it as
a base point, be able to regenerate the entire string again.


Answer: You can use [matplotlib](http://matplotlib.org/users/pyplot_tutorial.html) to
plot and
[ast.literal_eval](https://docs.python.org/2/library/ast.html#ast.literal_eval)
to evaluate your string:

    
    
    import matplotlib.pylab as plt
    from ast import literal_eval
    from operator import itemgetter
    
    with open("your_file") as f:
        lst = literal_eval(f.read())
        x,y = map(itemgetter(0),lst), map(itemgetter(1),lst)
        plt.plot(x,y)
        plt.show()
    

