[Scilab-users] subplot with 2 y-axis

Serge Steer Serge.Steer at inria.fr
Fri Oct 12 13:52:02 CEST 2012


Please find below  a code that realizes what you want
You have mainly forgotten to adapt the axes_bounds of the second axes
Serge Steer
INRIa

clf
Xangle  = [0. 10. 20. 30. 40. 50. 60. 70. 80. 90.];
cntangle = [10070 29822 33857 33522 36576 29697 23576 23138 23377 20000];
meanangle = [0.281 0.910 0.116 1.598 0.255 1.089 0.111 1.497 0.397 0.933];
stdvangle = [0.281 0.910 0.116 1.598 0.255 1.089 0.111 1.497 0.397 0.933];

subplot(2,1,1);
bar(Xangle,cntangle)
ymax=max(cntangle);
set(gca(),"data_bounds",[0,0;100 ymax+100],2,-1));
a=gca();    //get the handle of the newly created axes
a.x_label.text="Angle [degrees]";
a.y_label.text="Number [ ]";
a.auto_ticks = ["on","on","on"];


a1=newaxes();
a1.filled="off";

a1.axes_bounds=a.axes_bounds;
plot(Xangle,meanangle,'r-o',"MarkerSize",2,"MarkerFaceColor","r")
a1.data_bounds=[a.data_bounds(:,1) [0;3]];
a1.y_location = "right";
errbar(Xangle,meanangle,stdvangle/2.,stdvangle/2.);


Le 12/10/2012 13:20, W.Schulz a écrit :
> Hello,
> I try to make a subplot with 2 y-axis. I can create a single plot with 2
> y-axis but as soon as I add the subplot command (currently commented in the
> code below) the complete figure is distorted.
> What is the problem?
> Thanks
> Wolfgang
>
> clf
> Xangle  = [0. 10. 20. 30. 40. 50. 60. 70. 80. 90.];
> cntangle = [10070 29822 33857 33522 36576 29697 23576 23138 23377 20000];
> meanangle = [0.281 0.910 0.116 1.598 0.255 1.089 0.111 1.497 0.397 0.933];
> stdvangle = [0.281 0.910 0.116 1.598 0.255 1.089 0.111 1.497 0.397 0.933];
>
> //subplot(2,1,1);
> bar(Xangle,cntangle)
> ymax=max(cntangle);
> set(gca(),"data_bounds",matrix([0,100,0,ymax+100],2,-1));
> a=gca();    //get the handle of the newly created axes
> a.x_label.text="Angle [degrees]";
> a.y_label.text="Number [ ]";
> a.auto_ticks = ["on","on","on"];
>
> a=newaxes();
> a.filled="off";
>
> plot(Xangle,meanangle,'r-o',"MarkerSize",2,"MarkerFaceColor","r")
> set(gca(),"data_bounds",matrix([0,100,-3,3],2,-1));
> a.y_location = "right";
> errbar(Xangle,meanangle,stdvangle/2.,stdvangle/2.);
>
>
>
>
> --
> View this message in context: http://mailinglists.scilab.org/subplot-with-2-y-axis-tp4025009.html
> Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>




More information about the users mailing list