<jupyter_start><jupyter_text>Module 3: Advanced Matplotlib Graphing Assignment<NAME> July 25, 2021 BUAD 5112<jupyter_code>#Import matplotlib graphing package
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker

#Import pandas package
import pandas as pd

#Keep graphs within the Jupyter notebook
%matplotlib inline

#Import the ConstructionTimeSeriesDataV2.csv file
df_cts = pd.read_csv('ConstructionTimeSeriesDataV2.csv')

df_cts.insert(0, 'Date', pd.date_range(start = '2002-01-31', end = '2014-02-28', freq = 'M'))
df_cts = df_cts.set_index('Date')

fig, ax = plt.subplots()
fig.set_size_inches(14, 8)
fig.suptitle('Public & Private Construction Spending (Jan 2002-Feb 2014)', fontsize = 20)

ax.plot(df_cts['Total Construction'], label = 'Total Construction Spending')
ax.plot(df_cts['Private Construction'], label = 'Private Construction Spending')
ax.plot(df_cts['Public Construction'], label = 'Public Construction Spending')
ticks_loc = ax.get_yticks().tolist()
ax.yaxis.set_major_locator(ticker.FixedLocator(ticks_loc))
ax.set_yticklabels(['${:.0f}'.format(x) for x in ticks_loc])
ax.set_xlabel('Year', fontsize = 12) #X-axis caption
ax.set_ylabel('Construction Spending', fontsize = 12)
ax.set_ylim(0, 120000)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.axvspan(13818, 14426.5, ymin = 0, ymax = 150000, facecolor = 'k', alpha = 0.1)
ax.axvline(x = 13818, linewidth = 1, color = 'k', linestyle = '-')
ax.axvline(x = 14426.5, linewidth = 1, color = 'k', linestyle = '-')
ax.text(14500, 100000, 'The\nGreat\nRecession\n(12/07-06/09)', fontsize = 12, )
ax.axvspan(13514, 14244, ymin = 0, ymax = 150000, facecolor = 'k', alpha = 0.3)
ax.axvline(x = 13514, linewidth = 1, color = 'k', linestyle = '--')
ax.axvline(x = 14244, linewidth = 1, color = 'k', linestyle = '--')
ax.text(13450, 40000, 'Subprime\nMortgage\nCrisis\n(01/07-12/08)', horizontalalignment = 'right', fontsize = 12, )
ax.legend();<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1595959595959596, 'fraction_numerical': 0.08080808080808081, 'mean_word_length': 5.926573426573427, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '523373', 'license': 'CC0-1.0', 'n_tokens_mistral': 873, 'n_tokens_neox': 745, 'n_words': 167, 'path': 'plots/M3Graphing.ipynb', 'repo_name': 'stow13/stow13.github.io', 'size': '1984'}