views:

163

answers:

2

Hey Guys,

This seems like a basic problem with an easy answer but I simply cannot figure it out no matter how much I try.

I am trying to create a line graph based on two lists. For my x-axis, I want my list to be a set of strings.

x_axis_list = ["Jan-06","Jul-06","Jan-07","Jul-07","Jan-08"]
y_axis_list = [5,7,6,8,9]

Any suggestions on how to best graph these items?

+2  A: 
from pylab import *
from matplotlib.font_manager import FontProperties

dates = ["Jan-06","Jul-06","Jan-07","Jul-07","Jan-08"]
x_axis_list = range(len(dates))
y_axis_list = [5,7,6,8,9]

figure()
plot(x_axis_list, y_axis_list, "k")
xticks(x_axis_list, dates, rotation=45)
show()
ephes
ephes' answer above is an excellent simplest solution. If your date-times become more complex, you should look into using the plot_date helper function: http://matplotlib.sourceforge.net/examples/pylab_examples/date_demo2.html
Mark
A: 

Thank you very much! The "xticks" solved the problem.