无法多次获取pyplot 我在C++中使用了嵌入Python,在我的程序中,我必须运行Python模块很多次。不幸的是,plt.show() import matplotlib.pyplot as plt import numpy as np from matplotlib.patches import Ellipse, Circle import time def show(x,y,x1,y1): fig=plt.figure() fig.gca().invert_yaxis() ax1 = fig.add_subplot(111) cir1 = Circle(xy = (x1, y1), radius=0.02, alpha=0.5) ax1.add_patch(cir1) print len(x) print x1 ax1.set_title('Scatter Plot') plt.xlabel('X') plt.ylabel('Y') ax1.scatter(x,y,c = 'r',marker = 'o') plt.ion() plt.show() time.sleep(1) plt.close() return 'ok'

无法多次获取pyplot 我在C++中使用了嵌入Python,在我的程序中,我必须运行Python模块很多次。不幸的是,plt.show() import matplotlib.pyplot as plt import numpy as np from matplotlib.patches import Ellipse, Circle import time def show(x,y,x1,y1): fig=plt.figure() fig.gca().invert_yaxis() ax1 = fig.add_subplot(111) cir1 = Circle(xy = (x1, y1), radius=0.02, alpha=0.5) ax1.add_patch(cir1) print len(x) print x1 ax1.set_title('Scatter Plot') plt.xlabel('X') plt.ylabel('Y') ax1.scatter(x,y,c = 'r',marker = 'o') plt.ion() plt.show() time.sleep(1) plt.close() return 'ok',c++,python-2.7,C++,Python 2.7,试试,也许你需要先调用fig.show(),否则它就死了。试试,也许你需要先调用fig.show(),否则它就死了。

试试,也许你需要先调用
fig.show()
,否则它就死了。试试,也许你需要先调用
fig.show()
,否则它就死了。