Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting several images in the same plot

Tags:

matlab

I'm trying to plot small images on a larger plot... Actually its isomap algorithm, I got many points, now each point correspond to some image, I know which image is it... The porblem is how to load that image and plot on the graph? One more thing I have to plot both image and the points, so, basically the images will overlap the points. Certainly, the type of image given here

like image 639
batman Avatar asked Jan 26 '12 13:01

batman


People also ask

How do I display multiple images using subplot?

Create random data using numpy. Add a subplot to the current figure, nrows=1, ncols=4 and at index=1. Display data as an image, i.e., on a 2D regular raster, using imshow() method with cmap="Blues_r".

How do I show multiple images on Imshow?

imshow always displays an image in the current figure. If you display two images in succession, the second image replaces the first image. To view multiple figures with imshow , use the figure command to explicitly create a new empty figure before calling imshow for the next image.

How do you plot multiple things on one graph in Python?

In Matplotlib, we can draw multiple graphs in a single plot in two ways. One is by using subplot() function and other by superimposition of second graph on the first i.e, all graphs will appear on the same plot.


1 Answers

Something like this should get you started. You can use the low-level version of the image function to draw onto a set of axes.

% Define some random data
N = 5;
x = rand(N, 1);
y = rand(N, 1);

% Load an image
rgb = imread('ngc6543a.jpg');

% Draw a scatter plot
scatter(x, y);
axis([0 1 0 1]);

% Offsets of image from associated point
dx = 0.02;
dy = 0.02;

width = 0.1;
height = size(rgb, 1) / size(rgb, 2) * width;

for i = 1:N
  image('CData', rgb,...
        'XData', [x(i)-dx x(i)-(dx+width)],...
        'YData', [y(i)-dy y(i)-(dy+height)]);
end

enter image description here

like image 81
John Avatar answered Sep 28 '22 12:09

John