Can I change the axis scaling after plotting is done?

119 views (last 30 days)
Micke Malmström
Micke Malmström on 26 Apr 2011
I have a function that plots a graph with time on the x-axis, sometimes I want to change the scaling from s to ms or whatever.
Can I somehow do that without plotting it again and multiplying everything by 1e3?

Accepted Answer

Jan on 26 Apr 2011
You can modify the XData, the XTicks or the XTickLabels. The first method is most flexible, because it support zooming with correct tick marks:
t = linspace(0, 2*pi, 100);
LineH = plot(t, sin(t));
XData = get(LineH, 'XData');
set(LineH, 'XData', XData / 1000);

Community Treasure Hunt

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

Start Hunting!

Translated by