Ok, I have a possible workaround. It doesn't truly answer your question, but it might still achieve your aim?
You could shift the YTickLabels over so they don't overlap. I have two methods for doing this: one that only uses documented properties, but is a little messy, and one that uses an undocumented property:
Documented
This approach is to simply pad the YTickLabel strings with whitespace. You can get fancy trying to calculate how much whitespace, or just do a uniform padding:
fig = figure;
fig.Units = 'centimeters';
fig.Position(3:4) = [13 20];
plotPositions = [ 3, 13, 7, 6;
3, 7, 7, 6;
3, 1, 7, 6];
for i = 1:size(plotPositions,1)
hAx(i) = subplot(3, 1, i);
hAx(i).Units = 'centimeters';
scatter( hAx(i), 1:10, randi(10, 10, 1), 'bo')
hAx(i).Position = plotPositions(i,:);
hAx(i).XGrid = 'on';
hAx(i).YGrid = 'on';
end
for i = 1:2:size(plotPositions, 1)
yAxisLabels = hAx(i).YRuler.TickLabel;
paddingArray = repmat({' '},length(yAxisLabels),1);
yAxisLabelsPadded = strcat(yAxisLabels, paddingArray);
hAx(i).YRuler.TickLabel = yAxisLabelsPadded;
end
That example produces this result:
Undocumented Approach
In the HG2 system, there are a bunch of hidden properties for many graphics objects. Here I am using the TickLabelGapOffset property of the axes' YRuler objects.
fig = figure;
fig.Units = 'centimeters';
fig.Position(3:4) = [13 20];
plotPositions = [ 3, 13, 7, 6;
3, 7, 7, 6;
3, 1, 7, 6];
for i = 1:size(plotPositions,1)
hAx(i) = subplot(3, 1, i);
hAx(i).Units = 'centimeters';
scatter( hAx(i), 1:10, randi(10, 10, 1), 'bo')
hAx(i).Position = plotPositions(i,:);
hAx(i).XGrid = 'on';
hAx(i).YGrid = 'on';
end
for i = 1:2:size(plotPositions, 1)
oldGapOffset = hAx(i).YRuler.TickLabelGapOffset;
hAx(i).YRuler.TickLabelGapOffset = oldGapOffset + 20;
end
This approach looks very much the same, and produces this result:
Hopefully this helps! Good luck with your complex plotting :)
4 Comments
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/312535-how-do-i-put-minor-ticklabel-on-and-ticklabel-off#comment_406631
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/312535-how-do-i-put-minor-ticklabel-on-and-ticklabel-off#comment_406631
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/312535-how-do-i-put-minor-ticklabel-on-and-ticklabel-off#comment_406632
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/312535-how-do-i-put-minor-ticklabel-on-and-ticklabel-off#comment_406632
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/312535-how-do-i-put-minor-ticklabel-on-and-ticklabel-off#comment_406644
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/312535-how-do-i-put-minor-ticklabel-on-and-ticklabel-off#comment_406644
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/312535-how-do-i-put-minor-ticklabel-on-and-ticklabel-off#comment_406693
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/312535-how-do-i-put-minor-ticklabel-on-and-ticklabel-off#comment_406693
Sign in to comment.