I see your use of get_ylim() and set_ylim() but could not find a parameter that would take advantage of this. Seems you use it for volume for this exact purpose.
For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/