我的測試代碼爲什麼由pyplot繪製的邊框區域是黑色的?
import numpy as np
import time
import matplotlib
from matplotlib import pyplot as plt
def run(genxy, style='point'):
fig, ax = plt.subplots(1, 1)
#ax.set_aspect('equal')
ax.set_xlim(0, 5.2)
ax.set_ylim(-1.1, 1.1)
ax.hold(True)
plt.show(False)
plt.draw()
background = fig.canvas.copy_from_bbox(ax.bbox)
x, y = genxy.next()
if style == 'point':
sincurve = ax.plot(x, y, '.')[0]
else:
sincurve = ax.plot(x, y)[0]
while True:
try:
x, y = genxy.next()
except StopIteration:
break
sincurve.set_data(x, y)
# restore background
fig.canvas.restore_region(background)
# redraw just the points
ax.draw_artist(sincurve)
# fill in the axes rectangle
fig.canvas.blit(ax.bbox)
time.sleep(0.1)
plt.close(fig)
from copy import copy
X = np.arange(0, 5, 0.1)
def generate_curve(x):
x = copy(x)
y = np.sin(x)
for i in range(0, len(y)):
yield x[0:i+1], y[0:i+1]
genxy = generate_curve(X)
run(genxy, 'line')
而且屏幕顯示圖像是
而且更加有打印出來
QGtkStyle無法解析GTK警告。確保你已經安裝了 正確的庫。
我的python是2.7,我的系統是LMDE2(Linux Mint Debian Edition 2)。
我按照你的說法試過,但問題與以前一樣。 –