Functionalizing examples/pie_and_polar_charts

At Bloomberg day, as Tom requested turned the example scripts into functions to make them clearer.

Sorry about docstrings, I don't really write documentation at my day job.