fix(matlab): rate y-grid every 0.02 (was auto-subdividing to ~0.01)
MATLAB's minor grid ignored MinorTickValues and auto-subdivided finer than 0.02. Make 0.02 the actual (major) tick spacing for rate, label only every 0.1, and let grid on draw the fine 0.02 gridlines deterministically. Regenerated all figures. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -54,12 +54,20 @@ if strcmp(metric, 'count') % count: tick every 5, but label only every 10
|
|||||||
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
|
if mod(yt(k), 10) == 0; lbl{k} = num2str(yt(k)); else; lbl{k} = ''; end
|
||||||
end
|
end
|
||||||
set(gca, 'YTick', yt, 'YTickLabel', lbl);
|
set(gca, 'YTick', yt, 'YTickLabel', lbl);
|
||||||
else % rate: fine minor tick marks every 0.02 (no labels)
|
else % rate: tick every 0.02, label only every 0.1
|
||||||
yl = ylim(gca);
|
yl = ylim(gca);
|
||||||
set(gca, 'YMinorTick', 'on');
|
yt = 0 : 0.02 : ceil(yl(2) / 0.02) * 0.02;
|
||||||
ax = gca; ax.YAxis.MinorTickValues = 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
|
||||||
grid on
|
end
|
||||||
|
set(gca, 'YTick', yt, 'YTickLabel', lbl);
|
||||||
|
end
|
||||||
|
grid on % gridlines fall on the ticks (rate: every 0.02)
|
||||||
% Add breathing room between the y-axis label and the tick numbers.
|
% Add breathing room between the y-axis label and the tick numbers.
|
||||||
set(ylh, 'Units', 'normalized');
|
set(ylh, 'Units', 'normalized');
|
||||||
yp = get(ylh, 'Position');
|
yp = get(ylh, 'Position');
|
||||||
|
|||||||
Reference in New Issue
Block a user