matplotlib – How to plot subplots sharing the same datetime after applying sliding window?


I am having troubles making my subplots share the same x-axis(datetime) after performing sliding window to smoothen out the plot. I would like the datetime after windowing to share the same datetime as before windowing as illustrated in the picture below. I have also attached the codes to replicate the plots below.

enter image description here

from random import random
from datetime import datetime, timedelta
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

# Creating dummy datasets for illustration
date_example = ()
for i in range (0, 365):
    date_example.append(datetime(2020, 9, 1)+ timedelta(days = i))
    
values = ()
for _ in range (365):
    value = random()
    values.append(value)
    
date_example = pd.DataFrame(date_example)
values = pd.DataFrame(values)
example_set = pd.concat((date_example, values), axis =1, ignore_index=True)

# Creating sliding window on values dataset
wLen = 10     
values_windowed = (values(i*wLen : (i+1)*wLen) for i in range((len(values)+ wLen - 1)//wLen))

values_windowed_mean = np.zeros((len(values_windowed)))
for i in range(0,len(values_windowed)):
    values_windowed_mean(i) = np.mean(values_windowed(i)) 

# Plotting the plots
fig, ax = plt.subplots(2, figsize = (16,14))
ax(0).plot(date_example, values, label='Before Windowing')
ax(1).plot(np.linspace(0,70,num=len(values_windowed_mean), endpoint=True), values_windowed_mean, label='After Windowing')
ax(0).legend()
ax(1).legend()
plt.show()