| 104 | self.display() |
| 105 | |
| 106 | def build_ui(self): |
| 107 | self.fig = plt.figure() |
| 108 | ax = self.fig.add_subplot(111) |
| 109 | ax.axis("off") |
| 110 | lo = np.nanmin(self.xy, axis=0) |
| 111 | hi = np.nanmax(self.xy, axis=0) |
| 112 | center = (hi + lo) / 2 |
| 113 | w, h = hi - lo |
| 114 | ampl = 1.3 |
| 115 | w *= ampl |
| 116 | h *= ampl |
| 117 | ax.set_xlim(center[0] - w / 2, center[0] + w / 2) |
| 118 | ax.set_ylim(center[1] - h / 2, center[1] + h / 2) |
| 119 | ax.imshow(self.image) |
| 120 | ax.scatter(*self.xy.T, s=self.cfg["dotsize"] ** 2) |
| 121 | ax.add_collection(self.lines) |
| 122 | ax.invert_yaxis() |
| 123 | |
| 124 | self.lasso = LassoSelector(ax, onselect=self.on_select) |
| 125 | ax_clear = self.fig.add_axes([0.85, 0.55, 0.1, 0.1]) |
| 126 | ax_export = self.fig.add_axes([0.85, 0.45, 0.1, 0.1]) |
| 127 | self.clear_button = Button(ax_clear, "Clear") |
| 128 | self.clear_button.on_clicked(self.clear) |
| 129 | self.export_button = Button(ax_export, "Export") |
| 130 | self.export_button.on_clicked(self.export) |
| 131 | self.fig.canvas.mpl_connect("pick_event", self.on_pick) |
| 132 | |
| 133 | def display(self): |
| 134 | plt.show() |