Ok, with some support from belisarius, here is my comment as an answer: try a look at matplotlib . On the home page:
matplotlib is a python-based 2D graphics library that provides publication quality metrics in various formats on print media and in interactive environments across platforms. matplotlib can be used in python scripts, python and ipython shell (ala MATLAB® * or Mathematica®), web application servers and six GUI tools.
Initially, he was inspired by the possibilities of building MATLAB, although he has grown a lot since then. This is reliable software - and it is open source under the BSD license, so you can not only read the source code, but also hack it and use it anywhere.
Another place you can see is gnuplot . This is not one of the common open source licenses, but certainly open source, with some permissions to modify, etc.
Gnuplot is a portable command line graphical utility for Linux, OS / 2, MS Windows, OSX, VMS and many other platforms. The source code is protected by copyright, but freely distributed (i.e. you do not need to pay for it). It was originally created to allow scientists and students to interactively display math functions and data, but has grown to support many non-interactive applications such as web scripting. It is also used as a graphics engine by third-party applications such as Octave. Gnuplot has been supported and actively developed since 1986.
He also does 3D graphics, which matplotlib does not, and he has been around a lot longer. The reason I thought about matplotlib is because it is intended as a library for a higher level language, not a standalone application, so I assume it will be easier for you to read.
Another suggestion, just to get an idea of the things Mathematica is doing under the hood, is to look at the documentation for Plot . In particular, if you look at the available options, you can print everything.
MaxRecursion Automatic maximum number of recursive units is allowed. Method Automatic method used to refine PerformanceGoal curves $PerformanceGoal aspects to try to optimize the PlotPoints Automatic initial number of sample points
From MaxRecursion and PlotPoints you can see that it performs the initial sampling, and then somehow decides which regions need to be divided (resampled) to get the exact view of the plot. And from there, it's magic: for this there is Method , and PerformanceGoal is ...