refactor(matlab): simplify y-tick labels with yticks/yticklabels

Replace set(gca,'YTick'/'YTickLabel') + for-loop with yticks()/yticklabels()
and vectorized label-blanking (string array). Identical output (count: tick 5
label 10; rate: tick 0.02 label 0.1, grid every 0.02); PNGs unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Experiments DB Dev
2026-07-24 10:49:49 -04:00
parent 2885ad1eee
commit 31b4d87449
29 changed files with 232 additions and 522 deletions
+7 -17
View File
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');
@@ -46,27 +46,17 @@ set(gca, 'XTick', xd, 'XTickLabel', {}, 'Position', [0.2 0.30 0.60 0.60], ...
xticklabels('auto')
set(gca, 'XTickLabelRotation', 0); % keep x labels horizontal (no auto-rotate)
xlim([min(xd) - 0.5, max(xd) + 0.5]); % half-day padding so points aren't on the edges
if strcmp(metric, 'count') % count: tick every 5, but label only every 10
yl = ylim(gca);
yt = floor(yl(1) / 5) * 5 : 5 : ceil(yl(2) / 5) * 5;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
if strcmp(metric, 'count') % count: tick every 5, label only every 10
yt = 0 : 5 : ceil(yl(2) / 5) * 5;
lab = string(yt);
lab(mod(yt, 10) ~= 0) = "";
else % rate: tick every 0.02, label only every 0.1
yl = ylim(gca);
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
lbl = cell(1, numel(yt));
for k = 1:numel(yt)
if abs(yt(k) / 0.1 - round(yt(k) / 0.1)) < 1e-9 % multiple of 0.1
lbl{k} = num2str(round(yt(k), 1));
else
lbl{k} = '';
end
end
set(gca, 'YTick', yt, 'YTickLabel', lbl);
lab = string(round(yt, 1));
lab(mod(round(yt * 100), 10) ~= 0) = "";
end
yticks(yt); yticklabels(lab);
grid on % gridlines fall on the ticks (rate: every 0.02)
% Add breathing room between the y-axis label and the tick numbers.
set(ylh, 'Units', 'normalized');