axis in a plot in matlab

7 views (last 30 days)
Rica
Rica on 20 Feb 2013
Hi together
I have a plot. the x-axis is from 2:200. I want to show in the figure that x-axis is from 100:288. i know i could change it interactively, but i want to know if there is command to do this?
thank yyou

Accepted Answer

Walter Roberson
Walter Roberson on 20 Feb 2013
The easiest way is to add the offset to your x data when you plot. For example, instead of
plot(x,y)
use
plot(x+98, y)
but if that is not practical, the next best way is something like:
for h = findobj(gca, '-property, 'XData')
set(h, 'Xdata', 98 + get(h, 'Xdata'));
end
There are also ways that involve leaving the data lone and instead changing the label on the x axis so it looks like it is going 100:298. This method can be effective in stubborn circumstances, but it Does Not Play Well with zooming or datacursor.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!