# How to Make a Borderless Subplot of Images in MATLAB

Let’s say that you have a set of images that you want to tile using `imshow()` and `subplot()` in a MATLAB figure. By default, both functions add a padded space around the images to separate them, as this example shows:

Result:

However, what if you want to tile the images without any space between them? The `imshow()` function does have a property to remove the border around a displayed image, by using `imshow(I, 'border', 'tight')`. This is fine when only one image is being displayed, but `subplot()` itself adds additional spacing between images. Removing this space is not straightforward, but a gap-less subplot grid can be constructed by using the following function in place of `subplot()`:

By using this function, a completely borderless subplot of images can be constructed as follows:

Result:

## 12 comments on “How to Make a Borderless Subplot of Images in MATLAB”

• 1
Matt says:

Thanks Brian saved me a bunch of fiddling.

• 2
shavo says:

Thanks a lot.very useful!

• 3
Sina says:

Thank you so much,
Simple and useful!

• 4
Josephine says:

Thank You so much :) :D

• 5

Thanks!!! It is very useful.

• 6
rokP says:

King!!!

• 7
Alex says:

Is there an easy way to make a small border between the plots?

• 8
yt says:

Hi, nice code.

However, when I used for 2015b, for n>1, e.g. (10,10,i), there are spaces between images.

How can I fix it?

• 9
xing says:

Perfect solution, thanks so much!

• 10
Frank Smith says:

Thank you so much! Very useful!!!

• 11
Saima Tazreen says:

Hi

How do I combine multiple images with different sizes using this method?

• 12
Josie Johnson says:

This is a very confusing article and I do not understand it and it is not my job anyway. I am looking for a good essay writing site edu birdy and by mistake, I came on this article. But after completing my essay writing project with the use EduBirdie site I will do a study about this article and give my suggestion.