Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Question on python drawing line chart using pandas or matplotlib

I have a table like below:

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

Basically 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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

you can seaborn package. 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 to look at it’s basic documentation.
Here is the documentation for that.
https://seaborn.pydata.org/generated/seaborn.lineplot.html

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading