def imscatter(x, y, image_path, ax, zoom=1): """ function to plot an image at a point (x, y) on axis""" image = plt.imread(image_path) im = OffsetImage(image, zoom=zoom) im.set_zorder(10) x, y = np.atleast_1d(x, y) artists = [] for x0, y0 in zip(x, y): ab = AnnotationBbox(im, (x0, y0), xycoords='data', frameon=False) artists.append(ax.add_artist(ab)) ax.update_datalim(np.column_stack([x, y])) return artists
def imscatter(x, y, image, ax=None, zoom=2.): if ax is None: ax = plt.gca() try: image = plt.imread(image) except TypeError: pass im = OffsetImage(image, zoom=zoom, cmap=plt.get_cmap('gray')) im.set_zorder(10) x, y = np.atleast_1d(x, y) artists = [] for x0, y0 in zip(x, y): ab = AnnotationBbox(im, (x0, y0), xycoords='data', frameon=False) ab.set_zorder(10) artists.append(ax.add_artist(ab)) ax.update_datalim(np.column_stack([x, y])) ax.autoscale() return artists