Example of colorbar position and styles.
MGL code:
call 'prepare2d' new v 9 'x' subplot 2 2 0:title 'Colorbar out of box':box colorbar '<':colorbar '>':colorbar '_':colorbar '^' subplot 2 2 1:title 'Colorbar near box':box colorbar '<I':colorbar '>I':colorbar '_I':colorbar '^I' subplot 2 2 2:title 'manual colors':box:contd v a colorbar v '<':colorbar v '>':colorbar v '_':colorbar v '^' subplot 2 2 3:title '':text -0.5 1.55 'Color positions' ':C' -2 colorbar 'bwr>' 0.25 0:text -0.9 1.2 'Default' colorbar 'b{w,0.3}r>' 0.5 0:text -0.1 1.2 'Manual' crange 0.01 1e3 colorbar '>' 0.75 0:text 0.65 1.2 'Normal scale':colorbar '>':text 1.35 1.2 'Log scale'
C++ code:
void smgl_colorbar(mglGraph *gr) { gr->SubPlot(2,2,0); gr->Title("Colorbar out of box"); gr->Box(); gr->Colorbar("<"); gr->Colorbar(">"); gr->Colorbar("_"); gr->Colorbar("^"); gr->SubPlot(2,2,1); gr->Title("Colorbar near box"); gr->Box(); gr->Colorbar("<I"); gr->Colorbar(">I"); gr->Colorbar("_I"); gr->Colorbar("^I"); gr->SubPlot(2,2,2); gr->Title("manual colors"); mglData a,v; mgls_prepare2d(&a,0,&v); gr->Box(); gr->ContD(v,a); gr->Colorbar(v,"<"); gr->Colorbar(v,">"); gr->Colorbar(v,"_"); gr->Colorbar(v,"^"); gr->SubPlot(2,2,3); gr->Title(" "); gr->Puts(mglPoint(-0.5,1.55),"Color positions",":C",-2); gr->Colorbar("bwr>",0.25,0); gr->Puts(mglPoint(-0.9,1.2),"Default"); gr->Colorbar("b{w,0.3}r>",0.5,0); gr->Puts(mglPoint(-0.1,1.2),"Manual"); gr->Puts(mglPoint(1,1.55),"log-scale",":C",-2); gr->SetRange('c',0.01,1e3); gr->Colorbar(">",0.75,0); gr->Puts(mglPoint(0.65,1.2),"Normal scale"); gr->SetFunc("","","","lg(c)"); gr->Colorbar(">"); gr->Puts(mglPoint(1.35,1.2),"Log scale"); }