Skip to content

Instantly share code, notes, and snippets.

@fcunhaneto
Last active September 5, 2018 11:54
Show Gist options
  • Select an option

  • Save fcunhaneto/c56ac2a5e75ed8c447a9d67b3b77412f to your computer and use it in GitHub Desktop.

Select an option

Save fcunhaneto/c56ac2a5e75ed8c447a9d67b3b77412f to your computer and use it in GitHub Desktop.
Matplot annotates dentro de um box
import pandas as pl
import matplotlib.pyplot as plt
"""
Annotates dentro de um box
"""
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('PIB EUA Real Anual de 1909 a 1970')
# atributos para fonte:
# color - cor da fonte
# size - size in points or ['xx-small', 'x-small', 'small', 'medium', 'large',
# 'x-large', 'xx-large']
# weight - ['light' | 'ultralight' | 'normal' | 'bold' | 'heavy' | 'ultrabold'
# style - ['normal' | 'italic' | 'oblique']
# family - ['serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace']
plt.annotate(
'Fim da Segunda Gerra Mundial',
xy=(1945, 355.2),
color='red',
size='14',
arrowprops=dict(arrowstyle='->'), xytext=(1920, 500),
bbox = dict(boxstyle='round,pad=0.2', fc='yellow',
alpha=0.3),
)
plt.annotate(
'Crash da Bolsa', xy=(1929, 203.6),
arrowprops=dict(arrowstyle='->'),
xytext=(1909, 200),
color='yellow',
weight='heavy',
style='italic',
bbox = dict(boxstyle='round,pad=0.2', fc='red',
alpha=1),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment