From: jens on 17 Apr 2010 04:40 "Steven Lord" <slord(a)mathworks.com> wrote in message <hq9plc$81v$1(a)fred.mathworks.com>... > > "jens " <storebonghoved(a)hotmail.com> wrote in message > news:hq9i51$qd3$1(a)fred.mathworks.com... > > "Cris Luengo" <cris.luengo(a)google.for.my.name.to.contact.me> wrote in > > message <hq9968$38e$1(a)fred.mathworks.com>... > >> "jens " <storebonghoved(a)hotmail.com> wrote in message > >> <hq8son$dq6$1(a)fred.mathworks.com>... > >> > "jens " <storebonghoved(a)hotmail.com> wrote in message > >> > <hq76i9$htt$1(a)fred.mathworks.com>... > >> > > Hello Everybody > >> > > > >> > > I have the following code: > >> > > > >> > > e1=[10 30 40] > >> > > e2=[20 30 40] > >> > > y=[10 200 ; 20 300; 30 300] > >> > > f1 = @(x, y) bar(x, y,'group'); > >> > > f2 = @(x, y) bar(x, y,'group'); > >> > > [AX,H1,H2]=plotyy(1:length(y(:,1)),y,1:length(y(:,1)),y,f1) > >> > > get([AX(1) AX(2)],'xtick') > >> > > hold on > >> > > plotyy(y(:,1),e1,y(:,2),e2,'errorbar') > >> > > > >> > > I have a problem with the bar axes. One of the axis should show > >> > > values between [0 30] and the other axis should show values between > >> > > [0 300]. I also want that every column shows a standard deviation. > >> > > >> > > >> > Hey > >> > > >> > Somebody that can help? > >> > >> You're not getting help because people have no idea what you're trying to > >> accomplish. :) > >> > >> You plot the same data twice, on top of each other, in the first PLOTYY > >> command. What is the purpose of this? If you then scale the two axes > >> differently (which you can do with > >> set(AX(1),'ylim',[0,30]);set(AX(2),'ylim',[0,300]) ), you won't be able > >> to make sense at all of your data, since the left-axis bar plot will > >> completely hide the right-axis one. > >> > >> If you want to add error bars to your bar plot, you shouldn't use a > >> second PLOTYY, since this will create an additional 2 independent axes. > >> Try rewriting the f1 @function to do bar(...);hold on;errorbar(...) . > >> > >> Cheers! > > > > Thank you very much Chris > > > > I know the example above is not the best. I have two dataseries > > y1=[10;20;30] and y2=[200;300;300]. I want to create a barplot from the > > two dataseries and have two y-axes one for each dataserie. That is why I > > used plotyy. At the same time I want the standard deviation of each of the > > bars to be shown. Something like the example under, but the standard > > deviation of bar 4-6 are not right shown. What do you mean with "rewriting > > the f1 @function"? > > Write your own function that satisfies the conditions set out in PLOTYY for > the fifth and sixth input arguments [referred to as FUN, FUN1, and FUN2 in > the help for PLOTYY] and that plots your dataseries and the corresponding > error bars. Pass a handle to that function into PLOTYY as the fifth (and > sixth if necessary) input. > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > Hey Steve Thank you for your help. I tried to define a function called "input1" that defines the functions f1 and f2. The function input1 is used as the fifth input for the plotyy. I do not know how to couple the errorbar to the plot? I tried: function [f1,f2,f3]=input1(x,y,e1,e2) e=[e1 e2];%standard deviation f1=bar(x, y,'group'); f2=bar(x, y,'group'); f3=errorbar(x,y,e);%how do I couple the errorbar to the bar plots??? end And then in the command window I wrote: x=1:3 e1=[10 30 40] e2=[20 30 40] e=[e1 e2] y=[10 200 ; 20 300; 30 300] [AX,H1,H2]=plotyy(x,y(:,1),x,y(:,2),input1(x,y,e1,e2)) Best Regards Jens
From: jens on 17 Apr 2010 07:14 "jens " <storebonghoved(a)hotmail.com> wrote in message <hqbs58$pmk$1(a)fred.mathworks.com>... > "Steven Lord" <slord(a)mathworks.com> wrote in message <hq9plc$81v$1(a)fred.mathworks.com>... > > > > "jens " <storebonghoved(a)hotmail.com> wrote in message > > news:hq9i51$qd3$1(a)fred.mathworks.com... > > > "Cris Luengo" <cris.luengo(a)google.for.my.name.to.contact.me> wrote in > > > message <hq9968$38e$1(a)fred.mathworks.com>... > > >> "jens " <storebonghoved(a)hotmail.com> wrote in message > > >> <hq8son$dq6$1(a)fred.mathworks.com>... > > >> > "jens " <storebonghoved(a)hotmail.com> wrote in message > > >> > <hq76i9$htt$1(a)fred.mathworks.com>... > > >> > > Hello Everybody > > >> > > > > >> > > I have the following code: > > >> > > > > >> > > e1=[10 30 40] > > >> > > e2=[20 30 40] > > >> > > y=[10 200 ; 20 300; 30 300] > > >> > > f1 = @(x, y) bar(x, y,'group'); > > >> > > f2 = @(x, y) bar(x, y,'group'); > > >> > > [AX,H1,H2]=plotyy(1:length(y(:,1)),y,1:length(y(:,1)),y,f1) > > >> > > get([AX(1) AX(2)],'xtick') > > >> > > hold on > > >> > > plotyy(y(:,1),e1,y(:,2),e2,'errorbar') > > >> > > > > >> > > I have a problem with the bar axes. One of the axis should show > > >> > > values between [0 30] and the other axis should show values between > > >> > > [0 300]. I also want that every column shows a standard deviation. > > >> > > > >> > > > >> > Hey > > >> > > > >> > Somebody that can help? > > >> > > >> You're not getting help because people have no idea what you're trying to > > >> accomplish. :) > > >> > > >> You plot the same data twice, on top of each other, in the first PLOTYY > > >> command. What is the purpose of this? If you then scale the two axes > > >> differently (which you can do with > > >> set(AX(1),'ylim',[0,30]);set(AX(2),'ylim',[0,300]) ), you won't be able > > >> to make sense at all of your data, since the left-axis bar plot will > > >> completely hide the right-axis one. > > >> > > >> If you want to add error bars to your bar plot, you shouldn't use a > > >> second PLOTYY, since this will create an additional 2 independent axes. > > >> Try rewriting the f1 @function to do bar(...);hold on;errorbar(...) . > > >> > > >> Cheers! > > > > > > Thank you very much Chris > > > > > > I know the example above is not the best. I have two dataseries > > > y1=[10;20;30] and y2=[200;300;300]. I want to create a barplot from the > > > two dataseries and have two y-axes one for each dataserie. That is why I > > > used plotyy. At the same time I want the standard deviation of each of the > > > bars to be shown. Something like the example under, but the standard > > > deviation of bar 4-6 are not right shown. What do you mean with "rewriting > > > the f1 @function"? > > > > Write your own function that satisfies the conditions set out in PLOTYY for > > the fifth and sixth input arguments [referred to as FUN, FUN1, and FUN2 in > > the help for PLOTYY] and that plots your dataseries and the corresponding > > error bars. Pass a handle to that function into PLOTYY as the fifth (and > > sixth if necessary) input. > > > > -- > > Steve Lord > > slord(a)mathworks.com > > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > > > > Hey Steve > > Thank you for your help. I tried to define a function called "input1" that defines the functions f1 and f2. The function input1 is used as the fifth input for the plotyy. I do not know how to couple the errorbar to the plot? I tried: > > function [f1,f2,f3]=input1(x,y,e1,e2) > > e=[e1 e2];%standard deviation > f1=bar(x, y,'group'); > f2=bar(x, y,'group'); > f3=errorbar(x,y,e);%how do I couple the errorbar to the bar plots??? > > end > > And then in the command window I wrote: > > x=1:3 > e1=[10 30 40] > e2=[20 30 40] > e=[e1 e2] > y=[10 200 ; 20 300; 30 300] > > [AX,H1,H2]=plotyy(x,y(:,1),x,y(:,2),input1(x,y,e1,e2)) > > > Best Regards > > Jens Hey again Steve I found an error in my code, now I got a problem with function handle and still the errrobar is something wrong. function [f1,f2,f3]=input1(x,y,e1,e2,x2) x2=1:length(x)*2; y2=[y(:,1);y(:,2)]; e=[e1 e2];%standard deviation f1=bar(x, y,'group'); f2=bar(x, y,'group'); f3=errorbar(x2,y2,e);%how do I couple the errorbar to the bar plots??? end x=1:3 e1=[5 6 7] e2=[20 30 40] y=[10 200 ; 20 300; 30 300] [AX,H1,H2]=plotyy(x,y(:,1),x,y(:,2),input1(x,y,e1,e2)) I get the errror: ??? Error using ==> feval Argument must contain a string or function_handle. Error in ==> plotyy>fevalfun at 341 h = feval(func,x,y); Error in ==> plotyy at 61 [h1,ax(1)] = fevalfun(fun1,ax(1),x1,y1,caxspecified); Best Regards Jens
From: jens on 20 Apr 2010 02:04 "Steven Lord" <slord(a)mathworks.com> wrote in message <hqia52$jbd$1(a)fred.mathworks.com>... > > "jens " <storebonghoved(a)hotmail.com> wrote in message > news:hqc55t$arg$1(a)fred.mathworks.com... > > "jens " <storebonghoved(a)hotmail.com> wrote in message > > <hqbs58$pmk$1(a)fred.mathworks.com>... > >> "Steven Lord" <slord(a)mathworks.com> wrote in message > >> <hq9plc$81v$1(a)fred.mathworks.com>... > > *snip* > > > I found an error in my code, now I got a problem with function handle and > > still the errrobar is something wrong. > > > > function [f1,f2,f3]=input1(x,y,e1,e2,x2) > > > > x2=1:length(x)*2; > > y2=[y(:,1);y(:,2)]; > > e=[e1 e2];%standard deviation > > f1=bar(x, y,'group'); > > f2=bar(x, y,'group'); > > f3=errorbar(x2,y2,e);%how do I couple the errorbar to the bar plots??? > > > > end > > > > > > > > x=1:3 > > e1=[5 6 7] > > e2=[20 30 40] > > y=[10 200 ; 20 300; 30 300] > > > > [AX,H1,H2]=plotyy(x,y(:,1),x,y(:,2),input1(x,y,e1,e2)) > > > > I get the errror: > > > > ??? Error using ==> feval > > Argument must contain a string or function_handle. > > That's correct -- PLOTYY expects you to pass in a string or function handle > as the 5th (and 6th, if necessary) So try an anonymous function -- @(x, y) > input1(x, y, e1, e2) > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > Thanks for your help Steve I tried to use anonymous functions: x=1:3 e1=[5 6 7] e2=[20 30 40] y=[10 200 ; 20 300; 30 300] [AX,H1,H2]=plotyy(x,y(:,1),x+length(x),y(:,2),@(x,y,e1,e2)input1(x,y,e1,e2)) And function file: function [f1,f2,f3]=input1(x,y,e1,e2) x2=1:length(x)*2; y2=[y(:,1);y(:,2)]; e=[e1 e2];%standard deviation f1=bar(x, y,'group'); f2=bar(x, y,'group'); f3=errorbar(x2,y2,e);%how do I couple the errorbar to the bar plots??? end I got the errror: ??? Input argument "e1" is undefined. Error in ==> @(x,y,e1,e2)input1(x,y,e1,e2) Error in ==> plotyy>fevalfun at 341 h = feval(func,x,y); Error in ==> plotyy at 61 [h1,ax(1)] = fevalfun(fun1,ax(1),x1,y1,caxspecified); Error in ==> testsjov at 180 [AX,H1,H2]=plotyy(x,y(:,1),x+length(x),y(:,2),@(x,y,e1,e2)input1(x,y,e1,e2)) I think it is not possible to make a double barplot in matlab with standard deviation shown on each bar by using plotyy. I have used many hours on trying to find a solution on my problem. The nearest I have come to solve my problem is to use the code under where the standard deviations are shown for the green bars, but not for the blue bars? Best Regards Jens x=1:3 x2=4:6 y1=[10 20 30] y2=[200 300 300] y=[y2 y1] e1=[1 3 4] e2=[10 20 10] std=[1 2 3 10 20 20] [AX,H1,H2]=plotyy(x,y1,x+length(x),y2,input3(x2,y2,x,y))%,'fun')%input1(x,y1,e1),input2(x2,y2,e2)) hold on Max=round(max(y1))+5 Max1=round(max(y2))+50 ylim(AX(1), [0 Max]); ylim(AX(2), [0 Max1]); set(H1,'FaceColor','g'); set(H2,'FaceColor','b'); set(AX(1),'YColor','g') set(AX(2),'YColor','b') set(AX,'XGrid','on') set(AX,'YGrid','on') H1(2)=errorbar(1:3,y1,std(1:3),'+k') function [f5,f6]=input3(x2,y2,x,y) f5 = @(x2, y2) bar(x2, y2,0.6,'group'); f6 = @(x, y) bar(x, y1,0.6,'group'); end
From: Steven Lord on 20 Apr 2010 09:54 "jens " <storebonghoved(a)hotmail.com> wrote in message news:hqjg4k$g10$1(a)fred.mathworks.com... > "Steven Lord" <slord(a)mathworks.com> wrote in message > <hqia52$jbd$1(a)fred.mathworks.com>... *snip* >> That's correct -- PLOTYY expects you to pass in a string or function >> handle as the 5th (and 6th, if necessary) So try an anonymous function -- >> @(x, y) input1(x, y, e1, e2) *snip* >> > Thanks for your help Steve > > I tried to use anonymous functions: > > x=1:3 > e1=[5 6 7] > e2=[20 30 40] > y=[10 200 ; 20 300; 30 300] > [AX,H1,H2]=plotyy(x,y(:,1),x+length(x),y(:,2),@(x,y,e1,e2)input1(x,y,e1,e2)) No. Reread the example I gave and the section of HELP PLOTYY that discusses the 5th input argument. How does PLOTYY call that function? In particular, with how many input arguments does it call that function? You have two extra input arguments in your anonymous function that shouldn't be there. *snip* -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Steven Lord on 19 Apr 2010 15:15 "jens " <storebonghoved(a)hotmail.com> wrote in message news:hqc55t$arg$1(a)fred.mathworks.com... > "jens " <storebonghoved(a)hotmail.com> wrote in message > <hqbs58$pmk$1(a)fred.mathworks.com>... >> "Steven Lord" <slord(a)mathworks.com> wrote in message >> <hq9plc$81v$1(a)fred.mathworks.com>... *snip* > I found an error in my code, now I got a problem with function handle and > still the errrobar is something wrong. > > function [f1,f2,f3]=input1(x,y,e1,e2,x2) > > x2=1:length(x)*2; > y2=[y(:,1);y(:,2)]; > e=[e1 e2];%standard deviation > f1=bar(x, y,'group'); > f2=bar(x, y,'group'); > f3=errorbar(x2,y2,e);%how do I couple the errorbar to the bar plots??? > > end > > > > x=1:3 > e1=[5 6 7] > e2=[20 30 40] > y=[10 200 ; 20 300; 30 300] > > [AX,H1,H2]=plotyy(x,y(:,1),x,y(:,2),input1(x,y,e1,e2)) > > I get the errror: > > ??? Error using ==> feval > Argument must contain a string or function_handle. That's correct -- PLOTYY expects you to pass in a string or function handle as the 5th (and 6th, if necessary) So try an anonymous function -- @(x, y) input1(x, y, e1, e2) -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Multiplication of multidimensional arrays and computation speed Next: Centre y to x==0 in plot |