How can I get rid of the large invisible border of my MATLAB figure without cropping it?

B
BenjaminCowen · Oct 8, 2024 · 2.4K views
Question
Hey I have a question that would be super helpful to have an answer to. I am generating many MATLAB images. However, each image, when I copy figure to PPT, seems to have a large invisible box around it, which you can see when you click on the image. I know you can easily crop this out, but I don't want to crop many many images, and have to worry if the cropping is the same size. I want to copy these images into a Word document, and all the extra white space is not favorable. Is there a way to get that invisible box to just "hug" the image, instead of extending out several inches?
Expert Answer
Profile picture of Kshitij Singh
Kshitij Singh PhD Expert
Answered Nov 20, 2025

Try This:

clc; 
clear all ;
x = rand(20,1) ;
y = rand(20,1) ;
plot(x,y)
set(gca,'LooseInset',get(gca,'TightInset'));
saveas(gcf,'junk.jpg')

 

Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!