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

4 次查看(过去 30 天)
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.
.

请先登录,再进行评论。

更多回答(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