Axes changes while plotting during a for loop

I am using a for loop to plot multiple sets of data onto the same graph. I am runnning into the issue of when I run the "for loop", the figure is only capturing part of the data and not the entirity. If someone could explain why this is I would be greatful. Below is the code I am using and the picture that appears.
for i=1:NumBuildPlates
wblplot(B{i});
hold on
end
This is what appears but what I really want is the picture below without having to manually set the axes after it appears.
The picture below is what I want the loop to produce.

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 6월 17일

0 개 추천

Try adding this line at the end of your code
axis tight
For example
for i=1:NumBuildPlates
wblplot(B{i});
hold on
end
axis tight

댓글 수: 6

Okay, that was able to fix the x-axis but how would I go about fixing the y-axis?
It now looks identical to the 2nd picture i uploaded when I add "axis tight"
Do you want to have spacing along y-axis?
I just want the plot to fit y-axis. Similar to how it is fit on the first picture
Instead of axis tight, try the following line
xlim([-inf inf])
That worked perfectly for both the x and y axis.
If you mind me asking, how come xlim([-inf inf]) worked and not "axis tight"?
Nonetheless, thank you!
I am glad to be of help!
axis tight changes both x and y-axis, whereas xlim([-inf inf]) only fits the x-axis.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2020년 6월 16일

댓글:

2020년 6월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by