1

I have the following df

     time        x   count  model
0   2020-10-02  aaa     1   Hard 
1   2020-10-08  aaa     2   Hard 
2   2020-10-10  bbb     1   Hard 
3   2020-10-12  ccc     1   Hard 
4   2020-10-08  aaa     2   Easy
5   2020-10-10  bbb     1   Easy

I want to plot in the same graph x=time, y=count for each x in different colors for model==Hard

RAV
  • 11
  • 2
  • if `df` means pandas dataframe, use `groupby`. see the `groupby` section in the [accepted answer](https://stackoverflow.com/a/41494991/13138364) of [_Pandas dataframe groupby plot_](https://stackoverflow.com/q/41494942/13138364). – tdy Aug 25 '21 at 23:53

1 Answers1

0

For this type of needs, i recommend you to use plotly bar chart.

The code I would use :

import plotly.express as px

#Given a dataframe nammed df :

fig = px.histogram(df, x="time", y="count", color="model", barmode="group", histfunc="sum")
fig.show()

Sorry, but I don't fully understand your request to help you more. You may want to check this link to learn more about bar chart : https://plotly.com/python/bar-charts/#bar-chart-with-plotly-express

Clément Perroud
  • 483
  • 3
  • 12