0

I have the following code:

%matplotlib notebook
import matplotlib.pyplot as plt
import matplotlib
import numpy as np

fig, ax = plt.subplots(2,1, figsize=(10, 5))
plt.suptitle('My Data', x = 0.5, y =  1.0, fontsize = '8')

for i in range(0,2):
    l1, = ax[i].plot(data_df['col_A'][101:200] , color = 'black')
    l2, = ax[i].plot(data_df['col_B'][101:200], color = 'red')

plt.show()
plt.tight_layout()

enter image description here

And here is an output figure:

I am wondering if we could shift the entire red series to the left by 6 steps?

(I tried:

l2, = ax[i].plot(data_df_new['createvm_duration'][101-6:200-6], color = 'red')

which is not what I want because I want the x-axis ticks remain the same, but re-match of black and red peaks.)

Thanks!

Edamame
  • 23,718
  • 73
  • 186
  • 320

1 Answers1

2

Try shift the column by -6 before indexing it:

ax[i].plot(data_df['col_B'].shift(-6)[101:200], color = 'red')
Psidom
  • 209,562
  • 33
  • 339
  • 356