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."
|
|
0
|
|
|
|
Reply
|
Ken
|
3/26/2010 1:17:04 PM |
|
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?
--
|
|
0
|
|
|
|
Reply
|
dpb
|
3/26/2010 1:23:30 PM
|
|
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@non.net> wrote in message <hoiciu$mn7$1@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?
>
> --
|
|
0
|
|
|
|
Reply
|
Ken
|
3/26/2010 1:31:05 PM
|
|
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?
hold on
will retain last current axis and add
doc axes
to set a given axis as current.
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...
BTW, please don't top post -- it makes following conversation more
difficult than otherwise needs to be.
--
|
|
0
|
|
|
|
Reply
|
dpb
|
3/26/2010 1:45:47 PM
|
|
hi,
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). I can plot those graphs with multiple axes, but i want to highlight some points on the top of it, it just doesn't work.
Either it erases the previous graph or plot it on a new graph.
Thanks,
-ken
dpb <none@non.net> wrote in message <hoidst$tfn$1@news.eternal-september.org>...
> 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?
>
> hold on
>
> will retain last current axis and add
>
> doc axes
>
> to set a given axis as current.
>
> 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...
>
> BTW, please don't top post -- it makes following conversation more
> difficult than otherwise needs to be.
>
> --
|
|
0
|
|
|
|
Reply
|
Ken
|
3/26/2010 2:21:04 PM
|
|
Ken wrote:
....[top posting repaired...PLEASE don't do that]...
> dpb <none@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...
--
|
|
0
|
|
|
|
Reply
|
dpb
|
3/26/2010 2:38:22 PM
|
|
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@non.net> wrote in message
> <hoiciu$mn7$1@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.
|
|
0
|
|
|
|
Reply
|
Walter
|
3/26/2010 3:12:34 PM
|
|
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.
|
|
0
|
|
|
|
Reply
|
Walter
|
3/26/2010 3:17:55 PM
|
|
Thanks. It worked like a charm... ;-)
Walter Roberson <roberson@hushmail.com> wrote in message <hoiit2$jav$1@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@non.net> wrote in message
> > <hoiciu$mn7$1@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.
|
|
0
|
|
|
|
Reply
|
Ken
|
3/26/2010 3:18:03 PM
|
|
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...
--
|
|
0
|
|
|
|
Reply
|
dpb
|
3/26/2010 4:47:01 PM
|
|
|
9 Replies
364 Views
(page loaded in 0.086 seconds)
Similiar Articles: X and Y must be vectors of the same length. - comp.soft-sys.matlab ...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? hold on will retain last current axis and add ... adding vectors of different length - comp.soft-sys.matlab ...X and Y must be vectors of the same length. - comp.soft-sys.matlab ... hold on will retain last current axis and add doc ... x and an exogenous variable y which are ... inpolygon help - comp.soft-sys.matlabX and Y must be vectors of the same length. - comp.soft-sys.matlab ... inpolygon help - comp.soft-sys.matlab... must be the same size, and X represents the x value at each ... Surface Fitting toolbox (sftool) "weights"? - comp.soft-sys.matlab ...I would like to apply weighting to my z data but when I try to do this I get the error "x, y, z and weights must be the same length". I've obviously checked this and ... different length vectors -> one matrix - comp.soft-sys.matlab ...Hi all, I need to write a code for adding two vectors of different length, e.g. x=[1 9 ... different length vectors -> one matrix - comp.soft-sys.matlab ... probability ... vector splitting to many vectors - comp.soft-sys.matlabX and Y must be vectors of the same length. - comp.soft-sys.matlab ... vector splitting to many vectors - comp.soft-sys.matlab For example, I want to split a n x m long ... Write vector in term of x... - comp.soft-sys.matlabdifferent length vectors -> one matrix - comp.soft-sys.matlab ... X and Y must be vectors of the same length. - comp.soft-sys.matlab ... Write vector in term of x ... 3d plotting - comp.soft-sys.matlabI have three vectors X,Y and N1 Sizeof X is 1 330 Sizeof Y is 1 320 Size ... the same result as ... dimensions must agree. Hi, your 'X' vector has to match the size of ... plot 3d - comp.soft-sys.matlab... but a messag said that the size of vector dx and dy must be the same that ... that the X and Y be arrays the same size as Z, but newer versions allow X and Y to be vectors ... Error using quadl function - comp.soft-sys.matlab... quadl at 73 > > The integrand function must return an output vector of the same length as the > > input vector. > > help quadl > The function > Y=FUN(X ... X and Y must be vectors of the same length. - Newsreader - MATLAB ...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? hold on will retain last current axis and add X and Y must be vectors of the same length. - comp.soft-sys.matlab ...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? hold on will retain last current axis and add ... 7/25/2012 2:19:38 AM
|