I’m doing the Data Visualization in VSCode but the result didn’t go so well…
Below is my code
Adding the FiveThirtyEight style
import matplotlib.style as style
style.use(‘fivethirtyeight’)
Adding the plot
fig,ax = plt.subplots(figsize=(8,3))
ax.plot(financial_crisis[‘Time’],
financial_crisis['rolling_mean'],
linewidth=1, color='#A6D785')
Highlighting the 2007-2008 period
ax.plot(financial_crisis_7_8[‘Time’],
financial_crisis_7_8['rolling_mean'],
linewidth=3, color='#e23d28')
Highlihting the peak of the crisis
ax.axvspan(xmin=733112.0, xmax=733302.0, ymin=0.09,
alpha=0.3, color='grey')
Adding separate tick labels
ax.set_xticklabels()
ax.set_yticklabels()
x = 732272.0
for year in [‘2006’, ‘2007’, ‘2008’, ‘2009’, ‘2010’]:
ax.text(x, 1.13, year, alpha=0.5, fontsize=11)
x += 365
y = 1.193
for rate in [‘1.2’, ‘1.3’, ‘1.4’, ‘1.5’]:
ax.text(732172.0, y, rate, alpha=0.5, fontsize=11)
y += 0.1
Adding a title and a subtitle
ax.text(732172.0, 1.67, “Euro-USD rate peaked at 1.59 during 2007-2008’s financial crisis”,
weight='bold')
ax.text(732172.0, 1.63, ‘Euro-USD exchange rates between 2006 and 2010’,
size=12)
Adding a signature
ax.text(732172.0, 1.07, ‘©DATAQUEST’ + ’ '*94 + ‘Source: European Central Bank’,
color = '#f0f0f0', backgroundcolor = '#4d4d4d',
size=10)
Add some transparency to the grid
ax.grid(alpha=0.5)
plt.show()
What I expected to happen:
What actually happened:
Can someone help me pls:(