Function barh is the similar to bars but draw horizontal bars.
MGL code:
new ys 10 3 '0.8*sin(pi*(x+y/4+1.25))+0.2*rnd':origin 0 0 0 subplot 2 2 0 '':title 'Barh plot (default)':box:barh ys subplot 2 2 1 '':title '2 colors':box:barh ys 'cbgGyr' ranges -3 3 -1 1:subplot 2 2 2 '':title '"a" style':box:barh ys 'a' subplot 2 2 3 '': title '"f" style':box:barh ys 'f'
C++ code:
void smgl_barh(mglGraph *gr) { mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); gr->SetOrigin(0,0,0); if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Barh plot (default)"); } gr->Box(); gr->Barh(ys); if(big==3) return; gr->SubPlot(2,2,1,""); gr->Title("2 colors"); gr->Box(); gr->Barh(ys,"cbgGyr"); gr->SetRanges(-3,3,-1,1); // increase range since summation can exceed [-1,1] gr->SubPlot(2,2,2,""); gr->Title("'a' style"); gr->Box(); gr->Barh(ys,"a"); gr->SubPlot(2,2,3,""); gr->Title("'f' style"); gr->Box(); gr->Barh(ys,"f"); }