Prev: Redundancy & significance of canonical correlation results
Next: How to create an image from a binary mask file using RESHAPE?
From: jens on 18 Apr 2010 14:52 Hi everybody I have been trying to make a barplot with two y-axes. I have two dataseries y1 and y2 that I want to plot and at the same time I want to have the standard deviations e1 and e2 of the dataseries y1 and y2 to be shown. I have used the code under consisting of two function files input1(x,y1,e1) and input2(x2,y2,e2). I can make a bar plot with two y-axes. The green bar shows the y1 dataserie and the blue bar shows y2. Only the standard deviation of y1 is shown. Somehow I cannot get the standard deviation of the blue bar to be shown? I also tried to put the errorbar plot in the function files, but it did not work for me. When I search on the newsgroup I have not been able to find any solution. It seems like it is something not many have tried before. 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,input1(x,y1,e1),input2(x2,y2,e2)) ylim(AX(1), [0 50]); ylim(AX(2), [0 350]); set(H1,'FaceColor','g'); set(H2,'FaceColor','b'); set(AX(1),'YColor','g') set(AX(2),'YColor','b') hold on H1=errorbar(1:3,y1,std(1:3),'+r') hold on H2=errorbar(4:6,y2,std(4:6),'+r') function [f1]=input1(x,y1,e1) f1 = @(x, y) bar(x, y1,0.6,'group'); end function [f3]=input2(x2,y2,e2) f3 = @(x2, y2) bar(x2, y2,0.6,'group'); end
From: jens on 19 Apr 2010 10:40
"jens " <storebonghoved(a)hotmail.com> wrote in message <hqfkck$c3m$1(a)fred.mathworks.com>... > Hi everybody > > I have been trying to make a barplot with two y-axes. I have two dataseries y1 and y2 that I want to plot and at the same time I want to have the standard deviations e1 and e2 of the dataseries y1 and y2 to be shown. I have used the code under consisting of two function files input1(x,y1,e1) and input2(x2,y2,e2). I can make a bar plot with two y-axes. The green bar shows the y1 dataserie and the blue bar shows y2. Only the standard deviation of y1 is shown. Somehow I cannot get the standard deviation of the blue bar to be shown? I also tried to put the errorbar plot in the function files, but it did not work for me. When I search on the newsgroup I have not been able to find any solution. It seems like it is something not many have tried before. > > 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,input1(x,y1,e1),input2(x2,y2,e2)) > ylim(AX(1), [0 50]); > ylim(AX(2), [0 350]); > set(H1,'FaceColor','g'); > set(H2,'FaceColor','b'); > set(AX(1),'YColor','g') > set(AX(2),'YColor','b') > hold on > H1=errorbar(1:3,y1,std(1:3),'+r') > hold on > H2=errorbar(4:6,y2,std(4:6),'+r') > > > > function [f1]=input1(x,y1,e1) > > f1 = @(x, y) bar(x, y1,0.6,'group'); > end > > > function [f3]=input2(x2,y2,e2) > > f3 = @(x2, y2) bar(x2, y2,0.6,'group'); > end Hi Everybody Is there not anybody that can help me?I have really tried many options, but nothing works. I optimized my code, but I still cannot get the standard deviation of the blue bars to be shown? There must be someone that knows how to fix maybe the axes handle or what is needed? 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))%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(1)=errorbar(1:3,y1,std(1:3),'+k') hold on H2(1)=errorbar(4:6,y2,std(4:6),'+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 |