Home > OS >  How to draw line chart using pandas or matplotlib?
How to draw line chart using pandas or matplotlib?

Time:10-22

I have a table like below:

date  category  num
xxx      a       10
xxx      b       23
xxx      c       11
..........

I want to draw a line chart that: 1. x axis is the time series, 2. y is the num, and 3. each category gets their own line, so in the above case there should be 3 lines.

CodePudding user response:

Use seaborn lineplot.

sns.lineplot(x='date',y='num, data=df, hue='category',palette='bright) 

Using hue should give you 3 separate graph.

You can also use matplotlib. Here is the documentation for that: https://seaborn.pydata.org/generated/seaborn.lineplot.html

  • Related