0
我现在使用matplotlib
来尝试和可视化我正在处理的一些数据。我试图在同一图表上绘制大约6500点和线路y = x
,但在这样做时遇到了一些麻烦。我似乎只能得到要点而不是线条本身。我知道matplotlib
不会绘制方程式,而只是一组点,所以我试图使用相同的一组点来计算x和y坐标以生成线。使用Matplotlib绘制直线和分散点?
以下是我的代码
from matplotlib import pyplot
import numpy
from pymongo import *
class Store(object):
"""docstring for Store"""
def __init__(self):
super(Store, self).__init__()
c = Connection()
ucd = c.ucd
self.tweets = ucd.tweets
def fetch(self):
x = []
y = []
for t in self.tweets.find():
x.append(t['positive'])
y.append(t['negative'])
return [x,y]
if __name__ == '__main__':
c = Store()
array = c.fetch()
t = numpy.arange(0., 0.03, 1)
pyplot.plot(array[0], array[1], 'ro', t, t, 'b--')
pyplot.show()
任何建议,将不胜感激,
帕特里克
非常感谢。我只知道这是我做一些愚蠢的事情。精美的作品。 – 2010-06-16 16:37:32
@帕特里克 - 如果这是答案,为什么不将它标记为已接受? – tom10 2010-06-20 23:53:37
我的不好,我以为我有。 – 2010-06-21 09:18:27