【发布时间】:2023-03-13 12:05:01
【问题描述】:
我目前正在使用matplotlib 来尝试可视化我正在处理的一些数据。我试图在同一张图上绘制大约 6500 个点和线 y = x,但这样做时遇到了一些麻烦。我似乎只能得到要渲染的点,而不是线本身。我知道matplotlib 不会像这样绘制方程,而只是绘制一组点,所以我试图使用 x 和 y 坐标的相同点集来生成直线。
以下是我的代码
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()
如有任何建议,将不胜感激,
帕特里克
【问题讨论】:
标签: python matplotlib