Filter löschen
Filter löschen

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

4 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

Star Strider
Star Strider am 6 Mai 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 Kommentare
Star Strider
Star Strider am 6 Mai 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.
.
Star Strider
Star Strider am 7 Mai 2024
If my Answer helped you solve your problem, please Accept it!
.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by