-2

I need a bar graph with three columns at the y axis: rating_standard, rating_rapid, rating_blitz.

I attach a graph similar to my request.

df_7 = df3[(df3['fide_id'] == 14109336)]

df_7

fide_id year month rating_standard rating_rapid rating_blitz
146116 2015 1 2530.0 2599.0 2540.0
146116 2015 2 2530.0 2530.0 2530.0
.....
146116 2021 3 2546.0 2546.0 2546.0
146116 2021 4 2546.0 2521.0 2608.0

Look this

Loading
  • 1
  • 3
  • Im not sure I get your question, on the x-axis you mean[bottom]?? You could try a library. also, check this out, I think its python/graph related. https://stackoverflow.com/questions/606516/python-graph-library – Labaks. Feb 19 '23 at 12:47
  • Please try using plotly https://plotly.com/python/bar-charts/, this tutorial should explain how to do what you want – UpmostScarab Feb 19 '23 at 12:49
  • No it cannot be. It is often did with sex. I have three dfifferent colomns not one with two values. – Loading Feb 19 '23 at 12:51

1 Answers1

1

assuming your df_7 is a pandas DataFrame, there are two ways to do this:

easiest way:

df_7.plot(kind='bar',x='month',y=['rating_standard','rating_rapid','rating_blitz'])

another way using seaborn, you can first change the way the data is stored in it like this:

df = df.melt(id_vars=['month'], 
        value_vars=['rating_standard','rating_rapid','rating_blitz'], 
        var_name='rating',
        value_name='value', 
        )

it will make the table as:

    month   rating      value
0   1   rating_standard 2530.0
1   2   rating_standard 2530.0
2   3   rating_standard 2546.0
3   4   rating_standard 2546.0
4   1   rating_rapid    2599.0

where those rating columns are now a variable, i.e. each row in the original table now corresponds to 3 rows in the new table. Then you can use seaborn as the following:

import seaborn as sns
sns.barplot(data=df, x='month', y='value', hue='rating')

sample output

let me know if you want to be exactly like the image you shared, like the month names, colors, etc. then we can make some changes.

ses
  • 128
  • 5