Изображение загружается в отдельный класс с помощью следующей функции:
Код: Выделить всё
def load_image(self):
canvas = self.gui.dataPlot # Reference to matplotlibPlot widget
fig = plt.figure(1,canvas=canvas, figsize = (1.4,1.7))
self.ax = fig.add_subplot(111)
self.image = cv2.cvtColor(cv2.imread(self.images[self.c_im]), cv2.COLOR_BGR2RGB)
self.label_list[self.c_im]['image_name'] = self.images[self.c_im]
self.img_size_x = self.image.shape[1]
self.img_size_y = self.image.shape[0]
self.ax.clear()
im = self.ax.imshow(self.image)
plt.draw()
Код: Выделить всё
def create_rectangle(self, label):
xs = np.array([500, 1000, 1000, 500])
ys = np.array([500, 500, 1000, 1000])
poly = Polygon(np.column_stack([xs, ys]), animated=True, fill=True,closed=True, facecolor='white', alpha=0.1)
self.ax.add_patch(poly)
p = PolygonInteractor(self.ax, poly)
plt.show()
До сих пор я пробовал эти два варианта их удаления:
Код: Выделить всё
self.ax.clear()
[p.remove() for p in reversed(self.ax.patches)]
У кого-нибудь есть предложения, как их удалить?
Подробнее здесь: https://stackoverflow.com/questions/792 ... -from-plot
Мобильная версия