使用 PyLab 从两个单独的列表创建二维图 [英] Using PyLab to create a 2D graph from two separate lists
本文介绍了使用 PyLab 从两个单独的列表创建二维图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这似乎是一个简单的基本问题,但无论如何尝试,我都无法弄清楚.
This seems like a basic problem with an easy answer but I simply cannot figure it out no matter how much I try.
我正在尝试基于两个列表创建折线图.对于我的 x 轴,我希望我的列表是一组字符串.
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?
推荐答案
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()
这篇关于使用 PyLab 从两个单独的列表创建二维图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文