First, don't save line plots as JPG. It's unnecessarily destructive and it usually results in a bigger file for literally no benefit.
Unless you need to combine raster image content with plots or other graphics objects, don't use figures as a general image compositor. You will have no practical control over how the images are resized, and they will be subject to nearest-neighbor display interpolation by default, so thin line features will be easily destroyed. At this point you're literally taking a screenshot, resizing it blindly, and taking a screenshot of the screenshot. It gets worse every time. Don't save images by displaying them and taking screenshots of the figure. Save images directly using imwrite().
If you want to concatenate images of the same size, you can just concatenate them as you would any other array. You already know that, because you did concatenate them. You just didn't do anything with the concatenated image.
If they aren't of the same size, you can use padarray() or imresize() to resize them. If you want something that's more convenient, you can use imtile() to tile the images with whatever padding you want.
Compare the two examples:
We start by ruining our plot by saving it as a trash-quality 70% 4:2:0 JPG. Sample:
Then we blindly resize the images and take a screenshot of a bunch of resized screenshots.
inpict = imread('untitled.jpg');
Alternatively, we start by saving our plot as a clean, lightweight, lossless PNG. Sample:
Then we just combine the images into another image and then save the image like one would save an image.
inpict = imread('untitled.png');
outpict = imtile({inpict inpict inpict inpict},'gridsize',[2 2], ...
'bordersize',[10 10],'backgroundcolor',[0.5 0.3 0.8]);
imwrite(outpict,'composite.png')
Click on either of the output images to view them at full size.
Unreadable JPG composition:
- Image size: 970x1177 (resolution is not preserved, content is completely lost)
- Filesize: 78kB (file takes up more space)
Lossless PNG composition:
- Image size: 1282x1546 (resolution and content are preserved)
- Filesize: 65kB (file is actually smaller)