Last active
September 5, 2018 11:53
-
-
Save fcunhaneto/440e195b401317a89749fd36a233475a to your computer and use it in GitHub Desktop.
Matplot incluindo annotates
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
| import pandas as pl | |
| import matplotlib.pyplot as plt | |
| """ | |
| Incluindo annotates | |
| """ | |
| dataframe = pl.read_csv('annual-real-gnp-us-1909-to-1970.csv') | |
| plt.figure(figsize=(8, 6)) | |
| plt.plot(dataframe['Year'], dataframe['GNP']) | |
| plt.xlabel('Year') | |
| plt.ylabel('GNP') | |
| plt.title('Annual Real USA GNP 1909 to 1970') | |
| # matplotlib.pyplot.annotate(*args, **kwargs) | |
| # s:str - The text of the annotation | |
| # xy:iterable - Length 2 sequence specifying the (x,y) point to annotate | |
| # xytext : iterable, optional - Length 2 sequence specifying the (x,y) | |
| # to place the text at. If None, defaults to xy. | |
| # arrowprops: dict, optional | |
| plt.annotate('Fim da Segunda Gerra Mundial', xy=(1945, 355.2), | |
| arrowprops=dict(arrowstyle='->'), xytext=(1920, 300)) | |
| plt.annotate('Crash da Bolsa', xy=(1929, 203.6), | |
| arrowprops=dict(arrowstyle='->'), xytext=(1909, 200)) | |
| plt.savefig('gnp-us-1909-to-1970-annotate.png') | |
| plt.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment