user324333
user324333

Reputation: 31

Using PyLab to create a 2D graph from two separate lists

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?

Upvotes: 2

Views: 1849

Answers (1)

ephes
ephes

Reputation: 1461

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()

Upvotes: 5

Related Questions