mathGL就是用来绘制一些统计图形的一个CPP的库, 实际上就是和gnuplot类似的一个C++的库,很适合科学计算的结果分析和统计,另外还有QT,python等支持的接口,只是在编译库的时候要加上相应的option,这个库用起来很好,减少了很多工作量,其核心调用方式就是使用一个函数指针.
int mathgl_callback(mglGraph *gr) { const PolarFile* instance=PolarFile::instance(); if(instance->_data == NULL) return 0; if(instance->displayValidate()==false) return 0; gr->SubPlot(3,2,0); gr->Title("Jxx Intensity"); gr->Box(); gr->Dens(*(instance->_xx_norm)); gr->Colorbar(">"); gr->Axis(); gr->Label('y',"y",0); gr->Label('x',"x",0); gr->SubPlot(3,2,3); gr->Title("Jxx Phase/Pi"); gr->Box(); gr->Dens(*(instance->_xx_phas)); gr->Colorbar(">"); // gr->Puts(mglPoint(1.3,1.2),"unit Pi"); gr->Axis(); gr->Label('y',"y",0); gr->Label('x',"x",0); gr->SubPlot(3,2,1); gr->Title("Jxy Intensity"); gr->Box(); gr->Dens(*(instance->_xy_norm)); gr->Colorbar(">"); gr->Axis(); gr->Label('y',"y",0); gr->Label('x',"x",0); gr->SubPlot(3,2,4); gr->Title("Jxy Phase/Pi"); gr->Box(); gr->Dens(*(instance->_xy_phas)); gr->Colorbar(">"); gr->Axis(); gr->Label('y',"y",0); gr->Label('x',"x",0); gr->SubPlot(3,2,2); gr->Title("Jyy Intensity"); gr->Box(); gr->Dens(*(instance->_yy_norm)); gr->Colorbar(">"); gr->Axis(); gr->Label('y',"y",0); gr->Label('x',"x",0); gr->SubPlot(3,2,5); gr->Title("Jyy Phase/Pi"); gr->Box(); gr->Dens(*(instance->_yy_phas)); gr->Colorbar(">"); gr->Axis(); gr->Label('y',"y",0); gr->Label('x',"x",0); return 0; }
_p_mathgl = new QMathGL(this); _p_mathgl->setDraw(mathgl_callback); _p_mathgl->update()
参考资料:
http://mathgl.sourceforge.net/