import matplotlib.pyplot as plt
import pandas as pd
from mpl_ornaments.titles import set_title_and_subtitle

fig, ax = plt.subplots(nrows=1, ncols=1)

#1
df = pd.read_csv('data/top6-source-countries-us-imports.csv',
                 comment='#')
start_yr, end_yr = df['Year'].min(), df['Year'].max() 

#2
df = df[df['Country'] == 'China']

#3
ax.plot(df['Year'], df['Imports'], marker='o')

#4
ax.set_xticks(ticks=df['Year'].unique())
ax.set_ylim(bottom=0, top=700)

ax.spines[['right', 'top']].set_visible(False)

title = (f'United States imports from China ({start_yr}\u2012{end_yr})')
subtitle = ('Total imports in bn USD, goods only. '
            'Source: US Census Bureau.')
set_title_and_subtitle(fig=fig, title=title, subtitle=subtitle,
                       alignment='left', h_offset=35)

fig.savefig('charts/line-chart.png', dpi=300, bbox_inches='tight')