From: dpb on 26 Mar 2010 10:38 Ken wrote: ....[top posting repaired...PLEASE don't do that]... > dpb <none(a)non.net> wrote in message .... >> hold on >> >> will retain last current axis and add >> >> doc axes >> >> to set a given axis as current. >> .... > Thanks. The problem is as stated above. scatter tries to plot the > graph on a separate window no matter what I do to plot it on the same > one. Do you know how do I plot the on the top of an existing graph > some points? > Any simple examples would be fine especially with plotyy or the line > plots with multiple axes(2 y axes and 2 x axes on the same graph).... As noted previously, hold on and axes() % to set the desired axis >> x=rand(10,1);y=1./x; % make up some silly data >> ax=plotyy([1:10],x,[1:10],y); >> axes(ax(2)) % set current axis to rhand >> hold on % add, don't overwrite >> scatter([1:10],y) % do the point emphasis... >> puts the circles on the rhand axis... --
From: Walter Roberson on 26 Mar 2010 11:12 Ken wrote: > Thanks. I like to plot it on the same graph, not on a new graph. > Is there any other way to do it? > dpb <none(a)non.net> wrote in message > <hoiciu$mn7$1(a)news.eternal-september.org>... >> Ken wrote: >> > This is weird, I got this for the scatter plot even though for a >> single > point: >> > > [ax, h1, h2] = plotyy(x,y1, x,y2); >> > hold all; >> > scatter(ax, x(1), y(1), '*'); >> > hold off; >> > > It give me the following error: >> > > "X and Y must be vectors of the same length." >> >> doc scatter >> >> Why are you including the handle vector (length 2) from plotyy? The point is that ax is a -pair- of axis. You need to pass ax(1) or ax(2) to scatter.
From: Walter Roberson on 26 Mar 2010 11:17 dpb wrote: > I can't tell from your comment whether you grok that scatter() doesn't > accept an axis handle as an argument or not but to be clear at least in > my version it doesn't... Are you sure? Check out the second last calling syntax at http://www.mathworks.com/access/helpdesk/help/techdoc/ref/scatter.html The problem is that plotyy returns a pair of axes in the first parameter, and scatter notices the pair as a vector and assumes that they cannot be axes handles. Select a particular one of the axes returned from plotyy and (at least in current versions) you are good to go.
From: Ken on 26 Mar 2010 11:18 Thanks. It worked like a charm... ;-) Walter Roberson <roberson(a)hushmail.com> wrote in message <hoiit2$jav$1(a)canopus.cc.umanitoba.ca>... > Ken wrote: > > Thanks. I like to plot it on the same graph, not on a new graph. > > Is there any other way to do it? > > dpb <none(a)non.net> wrote in message > > <hoiciu$mn7$1(a)news.eternal-september.org>... > >> Ken wrote: > >> > This is weird, I got this for the scatter plot even though for a > >> single > point: > >> > > [ax, h1, h2] = plotyy(x,y1, x,y2); > >> > hold all; > >> > scatter(ax, x(1), y(1), '*'); > >> > hold off; > >> > > It give me the following error: > >> > > "X and Y must be vectors of the same length." > >> > >> doc scatter > >> > >> Why are you including the handle vector (length 2) from plotyy? > > The point is that ax is a -pair- of axis. You need to pass ax(1) or > ax(2) to scatter.
From: dpb on 26 Mar 2010 12:47
Walter Roberson wrote: > dpb wrote: > >> I can't tell from your comment whether you grok that scatter() doesn't >> accept an axis handle as an argument or not but to be clear at least >> in my version it doesn't... > > > Are you sure? Check out the second last calling syntax at > http://www.mathworks.com/access/helpdesk/help/techdoc/ref/scatter.html .... Which is why I put in the caveat "at least in my version it doesn't" to cover the possibility of an update. Even if so, passing the vector of handles is a gotcha' and his error message indicated scatter() didn't interpret the first argument as handles... -- |