Changing the axis property of matlab

I have the already plotted matlab figure and I want to change the x-axis value of the plot. I intend to multiply the old x -value by 1000 to get the new x which has to be shown in graph.
Can somebody help me with that?
Thanks

 Accepted Answer

José-Luis
José-Luis on 18 Feb 2013
Edited: José-Luis on 18 Feb 2013
h = plot(rand(10,1));
aH = ancestor(h,'axes');
x = get(h,'XData');
new_x = x .* 1000;
new_y = get(h,'Ydata');
delete(h);
plot(aH,new_x,new_y);
Alternatively, you could only change the XTickLabel:
h = plot(rand(10,1));
aH = ancestor(h,'axes');
x = get(aH,'XTick');
set(aH,'XTickLabel',sprintf('%d |',x.*1000));

3 Comments

Yes, this works out. The problem is that am using plot_dir function and plotting using the new x makes the plot out of range and is difficult. Is there anyways of changing the number only with out affecting the plot itself? thanks
Please see edited answer.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!