This is a question linked to this well received one. In that question I see an answers on how to plot images (or different images) at different coordinates like a scatter plot.
Using TextArea I can put little strings instead of images at different coordinates.
How about if I want to put a mini version of a plot/image generated by matplotlib itself? Suppose I want instead of using an image.jpg I want to use the result of plt.stem(arr) as the image in the scatter plots.
How can I do this? How about a miniature version of the output of plt.plot(x, y)?
I tried modifying the function given in the linked question to be like:
def stem_scatter(x, y, arr, ax=None): from matplotlib.offsetbox import AnnotationBbox, DrawingArea if ax is None: ax = plt.gca() im = DrawingArea(0.1, 0.1) im.add_artist(plt.stem(arr)) 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])) ax.autoscale() return artists But that gives an error: AttributeError: 'StemContainer' object has no attribute 'is_transform_set'
EDIT: From the linked question:
"…. but the second has a large advantage. The annotation box approach will allow the image to stay at a constant size as you zoom in." this would be a desirable feature in an accepted answer because on zooming in one would like to see the relative positions of the scatter points. If the scatter plotted image did not maintain a fixed size (relative to the screen as opposed to current axis limits), then zooming in would be of little help.
plt.savefigto save a picture, then use the method in the linked questioninset_axesapproach.