how to change the position of the axis data?
3 views (last 30 days)
Show older comments
how to change the position of the axis data? I want the numbers to be on the other side of the axis
something like this
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1185593/image.png)
0 Comments
Accepted Answer
Jan
on 8 Nov 2022
Edited: Jan
on 8 Nov 2022
% Dummy contents:
H = axes;
plot(1:10);
drawnow;
% Get original ticks:
XTick = H.XTick;
XLabel = H.XTickLabel;
nTick = numel(XTick);
% Calculate modified positions, omit the marginal ticks:
YL = H.YLim;
Ypos = repmat(YL(1) + (YL(2) - YL(1)) / 40, 1, nTick - 2);
text(XTick(2:nTick-1), Ypos, XLabel(2:nTick-1), ...
'HorizontalAlignment', 'center', 'VerticalAlignment', 'bottom')
% Remove original tick labels:
H.XTickLabel = {};
0 Comments
More Answers (0)
See Also
Categories
Find more on Axis Labels 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!