Need guidance in using function subplot

Hello
In a 2 * 2 mode, function subplot works well and the third and fourth places are assigned to the third image.
Example
subplot (2,2,1),imshow(pic1)
subplot (2,2,2),imshow(pic2)
subplot (2,2,[3,4]),imshow(pic3)');
But in a 4 * 5 mode, for example, I want a photo to be placed in places 3, 8, 13 , 18, what should I do ??
Thanks for your help

 Accepted Answer

Image Analyst
Image Analyst on 29 Nov 2020
Edited: Image Analyst on 29 Nov 2020
Try this:
% Put image into central column.
% Note: it will maintain the aspect ratio of the image
% and not be stretched vertically into a tall and skinny image.
subplot(4, 5, [3, 8, 13 , 18]);
imshow(pic);

7 Comments

Thanks for your help but my main problem is that I want to show the whole third column of the photo
My problem is that the photo is displayed in the third column
% and not be stretched vertically into a tall and skinny image.
Is there no way to solve this problem??
If your image is tall and skinny, it should show it that way, I'd think. Please upload your image so I can see where it's going wrong. There might be something you can do with the axis() or axes() command to warp your image to change it's aspect ratio to be abnormally tall and narrow.
I want to show that 8 people (8 photos) are on the left or right side of the river, and in the middle, in other words, places 3, 8, 13 and 18 are also photos of the river
OK, but is your (not uploaded yet) photo of the river tall and narrow?
Try this:
pic = imread('river.jpeg');
[rows, columns, numColors] = size(pic)
% Resize image to be 5 times as tall as it is wide
stretchFactor = 5;
pic = imresize(pic, [columns * stretchFactor, columns]);
for k = 1 : 20
subplot(4, 5, k);
text(0.5, 0.5, num2str(k));
end
% Put image into central column.
% Note: it will maintain the aspect ratio of the image
% and not be stretched vertically into a tall and skinny image.
subplot(4, 5, [3, 8, 13 , 18]);
imshow(pic);
The stretchFactor will vary depending on the shape and size of the figure so you might want to specify that in advance so that it looks the same on everyone else's computer.
Thank you very much
Thank you

Sign in to comment.

More Answers (0)

Products

Release

R2020b

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!