I have a multi-index dataframe that is sampled here:
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline
df = pd.read_csv('https://docs.google.com/uc?id=1mjmatO1PVGe8dMXBc4Ukzn5DkkKsbcWY&export=download', index_col=[0,1])
df
I tried to plot this so that each column ['Var1', 'Var2', 'Var3', 'Var4'] in a separate figure, the Country is a curve, and y-axis, and the Year is the x-axis
the requested figure would be like this Ms-Excel figure
I tried to plot it using
f, a = plt.subplots(nrows=2, ncols=2, figsize=(9, 12), dpi= 80)
df.xs('Var1').plot(ax=a[0])
df.xs('Var2').plot(ax=a[1])
df.xs('Var3').plot(x=a[2])
df.xs('Var4').plot(kax=a[3])
but it gives KeyError: 'Var1'
I also tried the following
f, a = plt.subplots(nrows=2, ncols=2,
figsize=(7, 10), dpi= 80)
for indicator in indicators_list:
for c, country in enumerate(in_countries):
ax = df[indicator].plot()
ax.title.set_text(country + " " + indicator)
but it returns 3 empty figures and one figure with all the data in it

What is wrong with my trials and What can I do to get what I need?



