From: Ken Kemal on 29 Mar 2010 05:57 Hi, I have the following code: figure ax= plotyy(x,y1, x,y2); axes(ax(2)); hold on; scatter(x1, y3, 'X'); scatter(x2, y4, 'O'); axes(ax(1)); hold on; scatter(x5, y5, 'O'); scatter(x5, y6, 'X'); hold off; I like to see both graphs with 'X' and 'O', but I am only getting one and the (x, y2) graph is missing. I know we can do it in Matlab. Can anyone show me what I did wrong? Many thanks, -ken
From: dpb on 29 Mar 2010 09:47 Ken Kemal wrote: > Hi, > > I have the following code: > > figure > ax= plotyy(x,y1, x,y2); > axes(ax(2)); > hold on; > scatter(x1, y3, 'X'); > scatter(x2, y4, 'O'); > axes(ax(1)); > hold on; > scatter(x5, y5, 'O'); > scatter(x5, y6, 'X'); > hold off; > > I like to see both graphs with 'X' and 'O', but I am only getting one > and the (x, y2) graph is missing. I know we can do it in Matlab. > > Can anyone show me what I did wrong? Not for sure since w/o actual data can't try to duplicate, but some comments... %figure % don't need this... ax= plotyy(x,y1, x,y2); % because this creates a figure hold on; % seems neater here to me... axes(ax(2)); scatter(x1, y3, 'X'); scatter(x2, y4, 'O'); axes(ax(1)); %hold on; % hold is already on... scatter(x5, y5, 'O'); scatter(x5, y6, 'X'); %hold off; % perhaps this is the culprit??? Otherwise, I'd wonder if the xi, yi pairs are out of scale range for the axis limits already set??? --
From: Ken Kemal on 29 Mar 2010 10:38 If you don't do figure and it will overwrite the current one. I removed figure, hold on and hold off and made no difference... I think there might be something that I am missing. dpb <none(a)non.net> wrote in message <hoqb4s$nfa$1(a)news.eternal-september.org>... > Ken Kemal wrote: > > Hi, > > > > I have the following code: > > > > figure > > ax= plotyy(x,y1, x,y2); > > axes(ax(2)); > > hold on; > > scatter(x1, y3, 'X'); > > scatter(x2, y4, 'O'); > > axes(ax(1)); > > hold on; > > scatter(x5, y5, 'O'); > > scatter(x5, y6, 'X'); > > hold off; > > > > I like to see both graphs with 'X' and 'O', but I am only getting one > > and the (x, y2) graph is missing. I know we can do it in Matlab. > > > > Can anyone show me what I did wrong? > > Not for sure since w/o actual data can't try to duplicate, but some > comments... > > %figure % don't need this... > ax= plotyy(x,y1, x,y2); % because this creates a figure > hold on; % seems neater here to me... > axes(ax(2)); > scatter(x1, y3, 'X'); > scatter(x2, y4, 'O'); > axes(ax(1)); > %hold on; % hold is already on... > scatter(x5, y5, 'O'); > scatter(x5, y6, 'X'); > %hold off; % perhaps this is the culprit??? > > Otherwise, I'd wonder if the xi, yi pairs are out of scale range for the > axis limits already set??? > > --
From: Walter Roberson on 29 Mar 2010 12:07 dpb wrote: > Not for sure since w/o actual data can't try to duplicate, but some > comments... > > %figure % don't need this... > ax= plotyy(x,y1, x,y2); % because this creates a figure > hold on; % seems neater here to me... dpb, you have forgotten that plotyy creates two axes, and that 'hold on' applies to gca only unless you use the hold(axis,'on') syntax. I have seen some hints from other postings this week that perhaps _neither_ of the two axes will be gca after the plotyy(), but I haven't bothered to test that. > axes(ax(2)); > scatter(x1, y3, 'X'); > scatter(x2, y4, 'O'); > axes(ax(1)); > %hold on; % hold is already on... > scatter(x5, y5, 'O'); > scatter(x5, y6, 'X'); > %hold off; % perhaps this is the culprit???
From: dpb on 29 Mar 2010 14:00 Walter Roberson wrote: > dpb wrote: > >> Not for sure since w/o actual data can't try to duplicate, but some >> comments... >> >> %figure % don't need this... >> ax= plotyy(x,y1, x,y2); % because this creates a figure >> hold on; % seems neater here to me... > > dpb, you have forgotten that plotyy creates two axes, and that 'hold on' > applies to gca only unless you use the hold(axis,'on') syntax. I have > seen some hints from other postings this week that perhaps _neither_ of > the two axes will be gca after the plotyy(), but I haven't bothered to > test that. .... Good point, Walter, I did indeed forget about the hold/current axis interaction altho I did remember that plotyy does create two axis objects... Experimentation here (and altho I don't recall the exact question, I recall answering a query very similar not long ago on plotyy) shows that gca returns ax(1) (lefthand axis) after ax=plotyy(...) I suppose again later versions could have differing behavior... --
|
Next
|
Last
Pages: 1 2 Prev: converting the size of expression Next: usb camera dll not recognised as valid adaptor |