Created
November 22, 2014 01:20
-
-
Save baldwint/2b6a653f6d53f4a4e748 to your computer and use it in GitHub Desktop.
Convenience function for adding a horizontal scalebar (aka sizebar) to axes. For a vertical sizebar, see https://gist.github.com/dmeliza/3251476
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
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar | |
def add_sizebar(ax, size, **kwargs): | |
kwargs.setdefault('label', str(size)) | |
kwargs.setdefault('loc', 4) | |
asb = AnchoredSizeBar(ax.transData, size, **kwargs) | |
ax.add_artist(asb) | |
return asb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment