Created
May 31, 2019 10:23
-
-
Save dtoma/fbdb777a4ffda80906daf83fb401d1e2 to your computer and use it in GitHub Desktop.
Center a plot on y=0
This file contains hidden or 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
| data = pd.Series(...) | |
| highest_point = abs(data.max()) | |
| lowest_point = abs(data.min()) | |
| max_y = max(highest_point, lowest_point) | |
| # Expand to the nearest order of magnitude (throws if max_y==0) | |
| max_y *= 10**int(math.log10(max_y)) | |
| data.plot(ylim=(-max_y, max_y)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment