Create a Student-Age graph in Python-Matplotlib
Question: 
    import matplotlib.pyplot as plt
    x = ['Eric','Jhon','bill','Daniel']
    y = [10, 17, 12.5, 20]
    plt.plot(x,y)
    plt.show()
    

When I run this code, I get this error `ValueError: could not convert string
to float:`

I want all names in list `x` at x-axis and corresponding ages are in second
list `y` which will be used in bar graph.

So here I have 1 more question Is it a good way to do in my case(I mean if we
can create a list of tuples(name,age)) and that would be easy?? or something
else.


Answer: The error occurs because matplotlib is expecting numerical data but you're
providing strings (the names).

What you can do instead is plot your data using some numerical data and then
replace the ticks on the x-axis using
[`plt.xticks`](http://matplotlib.org/1.3.1/api/pyplot_api.html#matplotlib.pyplot.xticks)
as below.

    
    
    import matplotlib.pyplot as plt
    
    names = ['Eric','John','Bill','Daniel']
    x = range(len(names))
    y = [10, 17, 12.5, 20]
    
    plt.plot(x, y)
    
    plt.xticks(x, names)
    
    plt.show()
    

![Plot example](http://i.stack.imgur.com/JHqwV.png)

