MATLAB: Semilogx() with reverse X Axis changes Y Labels position

MATLABsemilogxxdir

So when i try to plot a semilogx(…) with reverse xaxis something strange happens to the y Labels and i dont know how to fix this.
for example:
figure
y = ones(1,10000);
semilogx(y)
and then when i try to change the XDir property this happens:
set(gca,'XDir','reverse')
All the y ticks are on top of the y axis and i dont find any property to move them to the correct place.

Best Answer

That is a bug that has been fixed in R2019a (and perhaps earlier).
The only workaround seems to be to create separate 'YTickLabel' strings with spaces to the right to offset them from the y-axis:
figure;
plot(gca,0:2);
set(gca,'XDir','reverse')
yt = get(gca, 'YTick');
ytl = sprintfc('%.1f ', yt);
set(gca, 'YTick',yt, 'YTickLabel',ytl)
Change the spaces in the sprintfc format dexcriptor to get the result you want. (The sprintfc function is undocumented. You can also use the compose function if you have it.)