0

I want to graph 3 plots horizontally side by side

Three graphs are generated using the code below:

df.groupby(df.col1, pd.cut[0,1,2]).col2.mean().plot.bar()
df1.groupby(df.col1, pd.cut[0,1,2]).col2.mean().plot.bar()
df2.groupby(df.col1, pd.cut[0,1,2]).col2.mean().plot.bar()

I'm not sure where to set axes in this case. Any help would be appreciated.

jds
  • 59
  • 4

1 Answers1

0

You may simply use pandas' barh function.

df.groupby(pd.cut(df.col1, [0,1,2]).col2.mean().plot.barh()

This is an example, using this approach to create a dataframe with random samples:

import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))
df.groupby(pd.cut(df.A, [0,10,20,30,40,50,60,70,80,90,100])).A.mean().plot.barh()

This snippet outputs the following plot:

enter image description here

Sheldon
  • 4,084
  • 3
  • 20
  • 41
  • Sorry, I actually meants having 3 graphs, and display those horizontally side by side. Just edited the question to make it more clear – jds Jul 19 '22 at 03:02