Sometimes output plots contain surfaces with a lot of points, and some vector primitives (like axis, text, curves, etc.). Using vector output formats (like EPS or SVG) will produce huge files with possible loss of smoothed lighting. Contrary, the bitmap output may cause the roughness of text and curves. Hopefully, MathGL have a possibility to combine bitmap output for surfaces and vector one for other primitives in the same EPS file, by using rasterize command.
The idea is to prepare part of picture with surfaces or other "heavy" plots and produce the background image from them by help of rasterize command. Next, we draw everything to be saved in vector form (text, curves, axis and etc.). Note, that you need to clear primitives (use clf command) after rasterize if you want to disable duplication of surfaces in output files (like EPS). Note, that some of output formats (like 3D ones, and TeX) don’t support the background bitmap, and use clf for them will cause the loss of part of picture.
The sample code is:
// first draw everything to be in bitmap output gr->FSurf("x^2+y^2", "#", "value 10"); gr->Rasterize(); // set above plots as bitmap background gr->Clf(); // clear primitives, to exclude them from file // now draw everything to be in vector output gr->Axis(); gr->Box(); // and save file gr->WriteFrame("fname.eps");