Clear Filters
Clear Filters

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

4 views (last 30 days)
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?

Accepted Answer

Star Strider
Star Strider on 6 May 2024
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 Comments
Star Strider
Star Strider on 6 May 2024
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.
.

Sign in to comment.

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!