필터 지우기
필터 지우기

What is the best way to zoom this graph so there is no white space?

조회 수: 4 (최근 30일)
Grace
Grace 2024년 5월 6일
댓글: Star Strider 2024년 5월 7일
I can't seem to figure out the correct command that will change the dimension of the graph so that there is no white space on the right (see attached). Could someone please help me?

채택된 답변

Star Strider
Star Strider 2024년 5월 6일
pix = dir('*.png');
for k = 1:numel(pix)
figure
imshow(imread(pix(k).name))
end
Add this line after the plot:
xlim([min(intervalf) max(intervalf)])
I would add that to your code if I could, however I cannot run images of code.
.
  댓글 수: 5
Star Strider
Star Strider 2024년 5월 6일
I was going to suggest using the xticks function, however for whatever reason that doesn’t work as well as the old standby set function in this instance.
Try this —
functionf = @(x) exp(x) + 1;
intervalf = linspace(0, log(5), 1E+3);
figure
plot(intervalf, functionf(intervalf))
hold on
patch([intervalf flip(intervalf)], [zeros(size(intervalf)) flip(functionf(intervalf))], 'c')
hold off
xlim([min(intervalf) max(intervalf)])
title('Without ‘xticks’ and ‘set’')
figure
plot(intervalf, functionf(intervalf))
hold on
patch([intervalf flip(intervalf)], [zeros(size(intervalf)) flip(functionf(intervalf))], 'c')
hold off
xlim([min(intervalf) max(intervalf)])
xt = xticks;
xtnew = linspace(min(xt), max(xt), numel(xt)+2);
set(gca, 'XTick',xtnew, 'XTickLabel',compose('%.2f',xtnew))
title('With ‘xticks’ and ‘set’')
Make appropriate changes to get the result you want.
.
Star Strider
Star Strider 2024년 5월 7일
If my Answer helped you solve your problem, please Accept it!
.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by