[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?

Antworten (1)

Image Analyst
Image Analyst am 19 Dez. 2012

0 Stimmen

Use the xlim() and ylim() functions.

7 Kommentare

Shane
Shane am 19 Dez. 2012
can you integrate both functions with the plot?
and is it
xlim(plot(x,y));
???
Shane,
help xlim
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
Shane am 19 Dez. 2012
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
Jan
Jan am 19 Dez. 2012
@Shane: Besides Walter's suggestion, what about calling XLIM after all plots have been made?
Shane
Shane am 19 Dez. 2012
then it sets the limits and removes the plot >.<

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 19 Dez. 2012

Community Treasure Hunt

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

Start Hunting!

Translated by