There is no function that will allow you to create a tick label consisting of multiple lines.
As a workaround, you can replace the tick labels with text objects which can contain multiple lines of text. For example:
plot(1:10);
set(gca,'yticklabel',[], 'xticklabel', [])
yTicks = get(gca,'ytick');
xTicks = get(gca, 'xtick');
minX = min(xTicks);
VerticalOffset = 0.1;
HorizontalOffset = 0.6;
for yy = 1:length(yTicks)
text(minX - HorizontalOffset, yTicks(yy) - VerticalOffset, ['$$\begin{array}{c}',num2str( yTicks(yy)),'\\',num2str( 2*yTicks(yy)),'\end{array}$$'], 'Interpreter', 'latex')
end
minY = min(yTicks);
VerticalOffset = 0.6;
HorizontalOffset = 0.2;
for xx = 1:length(xTicks)
text(xTicks(xx) - HorizontalOffset, minY - VerticalOffset, ['$$\begin{array}{c}',num2str( xTicks(xx)),'\\',num2str( 2*xTicks(xx)),'\end{array}$$'], 'Interpreter', 'latex')
end
Best Answer