Removing extra white space on figure

Is there a way to get rid of the extra space below the spectrum so that it starts at 0? This seems to only occur for some of the figures I plot.

 Accepted Answer

When plotting, you can set after the plot command, the following:
ylim([0 valuethatyouwant])

5 Comments

Elham
Elham on 26 Jul 2022
Edited: Elham on 26 Jul 2022
I set
xlim([0 2048])
ylim([0 399999])
and when I hit RUN, the plots look fine, they start at 0. But for some reason when I combine multiple spectrum by copying and pasting them on top of eachother, the space shows up. Is there a way to change it without changing the code?
Can you post your code here?
%%Plot the area
b=(cell2mat(z));
maxz = find(max(b) == b);
figure('Name','Area')
hold on
plot(A(maxz*2048+1:(maxz+1)*2048),'LineWidth',1.5)
xlabel('Photon Energy(eV)','FontSize',11, 'FontWeight','bold')
ylabel('Harmonic Intensity(a.u.)','FontSize',11, 'FontWeight','bold')
title('Harmonic Intensity Using Ar','FontSize',12, 'FontWeight','bold')
set(gca,'FontWeight','bold','FontSize',10,'Color','white');
set(gca,'XTick',[])
hold off
xlim([0 2048])
ylim([0 399999])
Just changed the axes properties and it seems to be working fine now, thank you @Francesco Pignatelli !!
Glad to hear it! My pleasure :)

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!