0

I have a dataframe as below

        batsman      non_striker  partnershipRuns
0      SK Raina       A Flintoff               23
1      SK Raina         DR Smith               90
2      SK Raina     F du Plessis               36
3      SK Raina        JA Morkel               14
10     MS Dhoni    CK Kapugedera               18
11     MS Dhoni         DJ Bravo               51
12     MS Dhoni     F du Plessis               27
13     MS Dhoni        JA Morkel               12
14     MS Dhoni         JDP Oram                6

I have been able to create a stacked bar plot using

df1=df.pivot(columns='non_striker',index='batsman').fillna(0)
df1.plot(kind='bar',stacked=True,legend=True)

But this creates the legend over the plot which is quite ugly. enter image description here

Is there a way to position the legend to the side of the plot? Can the 'partnershipRuns' in each label be removed? Please let me know.

Thanks Ganesh

Tinniam V. Ganesh
  • 1,979
  • 6
  • 26
  • 51

0 Answers0