I have a dictionary of dataframes (Di):
JavaScript
x
7
1
Di = {}
2
groups = [2,3]
3
for grp in groups:
4
df = pd.DataFrame({'A' : (grp*2, grp*3, grp*4),
5
'B' : (grp*4, grp*5, grp*2)})
6
Di[grp] = df
7
For each df in Di, I would like to plot A against B in a single graph. I tried:
JavaScript
1
3
1
for grp in groups:
2
ax1 = Di[grp].plot(x='A', y='B')
3
But that gave me two graphs:
How do I get them both in the same graph please?
Advertisement
Answer
You should print on a same ax:
JavaScript
1
5
1
fig, ax = plt.subplots(figsize=(5,8))
2
3
for grp in groups:
4
Di[grp].plot(x='A', y='B',ax=ax)
5