How can I get separate plots for each columns(A,B,C,D) vs date side by side using python

Viewed 68

I have similar data as below in my pandas dataframe.

Date A B C D
01-01-2022 10000 1700 1457 327
02-01-2022 17000 3000 1245 526
03-01-2022 16000 2624 1478 632
04-01-2022 10138 1745 1325 800
05-01-2022 4761 1789 1475 952
06-01-2022 5000 1874 1423 1105
07-01-2022 3000 1965 1421 895
08-01-2022 4000 1847 1420 1410
09-01-2022 3001 1654 1418 564
10-01-2022 3002 1754 1417 1715
11-01-2022 3003 1598 1415 564
12-01-2022 3004 1515 1414 2020
13-01-2022 3005 1433 1412 564
14-01-2022 3006 1350 1411 2325
15-01-2022 3007 1268 1409 456

Table

How can I get separate plots side by side as date vs A, Date vs B, Date Vs C and so on, using python?

I am still learning, new to python and data visualization.

1 Answers

Try this, using pandas plot with subplots equal to True, and layout with (row, column) tuple:

df['Date'] = pd.to_datetime(df['Date'], format='%d-%m-%Y')
df.set_index('Date').plot(subplots=True, layout=(1,4), figsize=(15,7))

Output:

enter image description here

Related