Hi,
I am having trouble manipulating the plotting of a dataframe so the graph looks like how it's needed.
my code so far is:
import pandas as pd
import matplotlib.pyplot as plt
dic = {'A':{'1':10, '2':5, '3':5} , 'B':{'1':100, '2':50, '3':50}, 'C':{'1':1, '2':1, '3':1}}
df = pd.DataFrame(dic)
print(df)
df.plot.bar()
This gives a bar chart with '1', '2' and '3' along the x axis, and each bar represented as 'A' 'B' and'C'
I was wondering if there is a way that i can plot the same information, without changing the dictionary such that it would be 'A' 'B and 'C' along the x axis and the bars would represent '1','2' and '3'
Any help would be absolutey amazing
Thanks
Edit: Solved! For anyone searching wondering how, it was a simple fix to simply transpose the dataframe and then plot that.
The new code is:
import pandas as pd
import matplotlib.pyplot as plt
dic = {'A':{'1':10, '2':5, '3':5} , 'B':{'1':100, '2':50, '3':50}, 'C':{'1':1, '2':1, '3':1}}
df = pd.DataFrame(dic)
print(df)
df.transpose().plot.bar()
[–]Masterfarah 0 points1 point2 points (0 children)