Friday, November 4, 2016

Energy comparison plot revisited

     Looking back in my post about energy comparison graph,


is easy to see room for improvement. So in this one I'm sharing a code to make the same plot, but in much more pythonic way. Take a look in the code:


     In the first time I refused using "def" to define the function, thinking this would be overkill for a simple script, and would affect the readability. I was wrong, now the code bloat is reduced, and the readability is even better. The way python works, permitting that you define the parameter value inside an array (look at lines 31, 32, 33), keeps the readability, and also makes the order of the parameters in the array unimportant. Sweeeeeet.