[GUI] How do change the min and max values of a plot.

I want to change the min and max values of a plot in GUI.
And the following code doesn't work:
axis(handles.axes1,[0,100,0,1]);
This is because then when I plot a scatter after
scatter(handles.axes1, x, y);
It doesn't keep the same dimensions on the axes.
I then tried hold(handles.axes1);
between the two bits of code and it still doesn't work... confused.
What am I doing wrong?

Answers (1)

Use the xlim() and ylim() functions.

7 Comments

can you integrate both functions with the plot?
and is it
xlim(plot(x,y));
???
What? No! It just changes the min and max value of the axes - the range of values that's viewable in your graph. Just like if you double click the axis in Excel and set the starting and ending tick mark values. Isn't that what you were asking when you asked "change the min and max values of a plot"?
plot() returns a handle to the line you plotted - that doesn't even make sense to send into xlim. You'd use xlim like this:
xlim([0 100]);
if you wanted to show your data in the 0-100 range and did not like whatever range it picked for you automatically.
Doesn't work.
When I set the limits of the axis and then subsequently plot any graph it auto sets the axis again.
This is the problem I am having.
Thanks, Shane
@Shane: Besides Walter's suggestion, what about calling XLIM after all plots have been made?
then it sets the limits and removes the plot >.<

Sign in to comment.

Categories

Asked:

on 19 Dec 2012

Community Treasure Hunt

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

Start Hunting!