[GUI] How do change the min and max values of a plot.
Show older comments
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)
Image Analyst
on 19 Dec 2012
0 votes
Use the xlim() and ylim() functions.
7 Comments
Shane
on 19 Dec 2012
Matt Fig
on 19 Dec 2012
Shane,
help xlim
Image Analyst
on 19 Dec 2012
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.
Shane
on 19 Dec 2012
Walter Roberson
on 19 Dec 2012
hold all
Jan
on 19 Dec 2012
@Shane: Besides Walter's suggestion, what about calling XLIM after all plots have been made?
Shane
on 19 Dec 2012
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!