Skip to content

Instantly share code, notes, and snippets.

import pandas as pd
import matplotlib.pyplot as plt
# get input data
df = pd.read_csv('./gdp_capita.csv')
ax = df.plot.bar(x='Year', width=0.8)
ax.set_ylabel('GDP/capita (USD)')
for container in ax.containers:
import pandas as pd
import matplotlib.pyplot as plt
# get input data
df = pd.read_csv('./gdp_capita.csv')
ax = df.plot.bar(x='Year')
ax.set_ylabel('GDP/capita (USD)')
plt.tight_layout()
plt.show()
# import necessary libraries
import pandas as pd
import matplotlib.pyplot as plt
# get input data
df = pd.read_csv('./data.csv')
ax = df.plot(x='Year', y='Item 1',
kind='bar')
ax.set_ylabel("Price (USD)")
# import necessary libraries
import pandas as pd
import matplotlib.pyplot as plt
# get input data
df = pd.read_csv('./data.csv')
ax = df.plot(x='Year', y='Item 1',
kind='bar')
ax.set_ylabel("Price (USD)")
Year Item 1
1990 5
1995 7
2000 10
2005 12
2010 15
2015 18
2020 22
Year Item 1 Item 2
1990 5 2
1995 7 4
2000 10 6
2005 12 8
2010 15 10
2015 18 12
2020 22 14