python error "ValueError: Invalid vertices array"
Question: I'm running the following code and get the following error for making the
plot. When I print the cov variable, the numbers in it have single quotes
around them. I'm assuming this is the problem? When I try to plot x and y, it
works just fine. I'm a new python user. Any suggestions? Thanks!

    
    
    #!/bin/python
    
    import matplotlib.pyplot as plt
    import matplotlib.cm as cm
    import numpy as np
    from sys import argv
    #from numpy import array
    
    #array = numpy.float64(array)
    
    script, filename = argv
    
    file = open(filename)
    
    pos = []
    cov = []
    
    for line in file:
        if (line.split()[0])=='1':
            ch = int(line.split()[0])
            #adjpos = int(line.split()[1])
            pos.append(line.split()[1])
            cov.append(line.split()[2])
    
    file.close()
    
    print cov
    
    x = [0, 1, 2, 3]
    y = [5, 10, 5, 5]
    
    print x
    print y
    
    fig = plt.figure(figsize=(16,3),edgecolor='w')
    plt.scatter(pos,cov,marker='.',s=1)
    plt.show()
    
    Traceback (most recent call last):
      File "/Users/eflannery/Dropbox/plotSamFlags.py", line 37, in <module>
        plt.scatter(pos,cov,marker='.',s=1)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 2557, in scatter
        ret = ax.scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, faceted, verts, **kwargs)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.py", line 5876, in scatter
        self.add_collection(collection)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.py", line 1445, in add_collection
        self.update_datalim(collection.get_datalim(self.transData))
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/collections.py", line 160, in get_datalim
        offsets = transOffset.transform_non_affine(offsets)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/transforms.py", line 1925, in transform_non_affine
        self._a.transform(points))
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/transforms.py", line 1415, in transform
        return affine_transform(points, mtx)
    ValueError: Invalid vertices array.
    


Answer: The numbers need to be converted to a type that matplotlib can use; right now
it just makes a list of strings, as `split()` returns a list of strings. You
can fix this by calling `int()` (or `float()`, if the numbers aren't all
integers) to convert the strings when you read the file, which you already did
in the assignment to `ch`:

    
    
    for line in file:
        if (line.split()[0])=='1':
            ch = int(line.split()[0])
            pos.append(int(line.split()[1]))
            cov.append(int(line.split()[2]))
    

