Reputation: 103
In MATLAB, I want to reverse my x-axis, but I dont actually want to reverse the image/graph when doing this. I want the image/graph to remain unchanged while I simple reverse the x-axis ticks.
Upvotes: 0
Views: 451
Reputation: 899
x=0:10;
y=x.^2;
plot(x,y);
set(gca,'XTickLabel',fliplr(x));
EDIT: To select the amount of decimals, use:
set(gca,'XTickLabel',sprintf('%.2f |',fliplr(x)'));
where 2
is the number of decimals that you want
Upvotes: 2
Reputation: 12214
You can do this by modifying the XTickLabel
property of your axis
object:
x = 1:10;
axishandle = axes;
plot(x)
oldticks = get(axishandle,'XTickLabel');
newticks = fliplr(str2num(oldticks).');
set(axishandle,'XTicklabel',newticks);
Upvotes: 0