Can I change the axis scaling after plotting is done?

Anderson85 · Aug 26, 2020 · 1.9K views
Question
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?
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Aug 23, 2026

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));
pause(1.0);
XData = get(LineH, 'XData');
set(LineH, 'XData', XData / 1000);
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!