making the graphic smaller

5 views (last 30 days)
Cansu
Cansu on 19 Apr 2025
Answered: Benjamin Kraus on 28 May 2025
hello, i am using the version 2024b, and i need help with something. in my figure window there's an ekg signal and i want to make the ekg signal smaller only, not the figure window. scaling didnt help, maybe i did it wrong? i want it to look like the ones u get at the hospital; big paper, small looking signal. any tips?

Answers (3)

Walter Roberson
Walter Roberson on 19 Apr 2025
Generally speaking, what you would do is set the axes Position property smaller. You would probably tend to move the axes at the same time.
For example, shrinking the axes to 2/3 of its existing size:
ax = gca;
ax.Position(3:4) = ax.Position(3:4) * (2/3);

Benjamin Kraus
Benjamin Kraus on 28 May 2025
Riffing off @William Rose's answer:
If your goal is a specific aspect ratio in your axes, both on-screen and/or exported, you want to set either the PlotBoxAspectRatio or the DataAspectRatio of your axes, or both. There are shortcut commands pbaspect and daspect. You can read their doc pages for more details, but pbaspect will allow you to tell MATLAB to force the axes plot box (the white part) to have a specific aspect ratio (ratio between the height and width of the white part of the axes) and daspect will let you tell MATLAB to fix a specific ratio between the height of a data unit in the y-direction and the width of a data unit in the x-direction.
I'm not familiar with the specifics of ECGs, but starting with @William Rose's answer and seaching on Google, the small squares in an ECG are 0.04s wide and 0.1mV tall and the large squares are 0.2s wide and 0.5mV tall. To achive similar look in MATLAB:
f = figure;
f.Units = 'centimeters';
f.Position = [0 0 75 10];
ax = axes;
t = [0 3]; % time span in seconds
v = [-0.5 0.5]; % voltage span in mV
dt = 0.2; % time step per large box in seconds
dv = 0.5; % voltage per large box in mV.
pbaspect([1/25 1/10 1])
daspect([1/25 1/10 1])
xlim(t)
ylim(v)
ax.XAxis.TickValues = t(1):dt:t(2);
ax.XAxis.MinorTickValues = t(1):(dt/5):t(2);
ax.YAxis.TickValues = v(1):dv:v(2);
ax.YAxis.MinorTickValues = v(1):(dv/5):v(2);
grid('on')
grid('minor')
That will let you set the on-screen ratio, then when you export you just need to make sure the exported size is consistent with you expected sizes.

William Rose
William Rose on 27 May 2025
Matlab functions exportgraphics() and print() allow you to specify the size of the figure that is created.
You wrote "i want it to look like the ones u get at the hospital; big paper, small looking signal. "
There is a standardized scaling for the hardcopy display of the ECG: 10 mm/mV and 25 mm/s. You can acheive this standard scaling with exportgraphics(). It is more difficult with print(), because print() includes whitespace around the figure, which is difficult to account for when doing the scaling. exportgraphics exports a tightly cropped figure, by default.
The exportgraphics() options to set units, height, and width are only available with Matlab Online starting with R2024a, and with Matlab-on-your-computer starting with R2025a. If you are using an earlier version, it will be trickier.

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!