Created
November 15, 2015 11:11
-
-
Save gauden/c8bee41a32c8196ee5b1 to your computer and use it in GitHub Desktop.
Convenience function to pad the axes in matplotlib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pad_axis(ax, pct=2.0): | |
for dim in ('x', 'y'): | |
getter = ax.get_xlim if dim =='x' else ax.get_ylim | |
setter = ax.set_xlim if dim =='x' else ax.set_ylim | |
lo, hi = getter() | |
pad = (hi-lo) / 100.0 * pct | |
setter(lo-pad, hi+pad) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment