0

my dataframe of pivot is looking like this.

 df=
                   DATA
Type            P_A       P_B
Time        
11:38:56    500706.0    981098.0
11:39:46    501704.0    984751.0
11:40:26    501704.0    984737.0
11:43:18    502758.0    987173.0

I want to plot this dataframe. df.plot() is works but since values are very much different on scale so ploting needs to be on different axis . How to do that?

Suraj Shejal
  • 640
  • 3
  • 19

2 Answers2

0

plot has an option secondary_y:

import pandas as pd
df = pd.DataFrame({'Time':['11:38:56', '11:39:46', '11:40:26', '11:43:18'],
                   'P_A': [500706., 501704., 501704., 502758.],
                   'P_B': [981098., 984751., 984737., 987173.]})
df.plot(x='Time', y=['P_A','P_B'], secondary_y=['P_B'])
Stef
  • 28,728
  • 2
  • 24
  • 52
0

Try using secondary axis-argument to pandas plot as suggested here.

df['P_A'].plot()
df['P_B'].plot(secondary_y=True)
Toivo Mattila
  • 377
  • 1
  • 9