我正在尝试使它能够运行一个无限循环,请求用户输入以及运行matplotlib简单图。有什么建议吗?目前我的代码有:
def createGraph():
fig = plt.figure()
fig.suptitle('A Graph ', fontsize=14, fontweight='bold')
ax = fig.add_subplot(111)
fig.subplots_adjust(top=.9)
ax.set_xlabel('X Score')
ax.set_ylabel('Y Score')
plt.plot([1,2,3,4,5,6,7],[1,3,3,4,5,6,7], 'ro')
plt.show()
def sub_proc(q,fileno):
sys.stdin = os.fdopen(fileno) #open stdin in this process
some_str = ""
while True:
some_str = raw_input("> ")
if some_str.lower() == "quit":
return
q.put_nowait(some_str)
if __name__ == "__main__":
q = Queue()
fn = sys.stdin.fileno() #get original file descriptor
qproc = Process(target=sub_proc, args=(q,fn))
qproc.start()
qproc.join()
zproc = Process(target=createGraph)
zproc.start()
zproc.join()
如您所见,我正在尝试让进程来实现这一点,因此代码是并行工作的。最终,我希望用户能够显示一个图形,同时能够在控制台中输入。谢谢你的帮助!!在
这是你想要的吗?在
我想我在评论中让你走了一条太复杂的路
相关问题 更多 >
编程相关推荐