You have the function pd.date_range() of the bookstore Pandas that makes you this simple.Just to pd.date_range(<fecha_inicio>, <fecha_fin>) We put a start date and one end date. Here is the code of your example:import pandas as pd
import matplotlib.pyplot as plt
array = ['309', '307', '303', '296', '322', '340', '321', '314', '327', '315', '316', '333', '296', '286', '289', '290', '316', '317', '333', '348', '398', '396', '404', '424', '402', '357', '320', '315', '321', '328', '312', '293', '302', '296', '286', '281', '281', ' 0', '312', '326', '332', '293', '242', '259', '268', '316', '296', '303', '280', '308', '314', '298', '307', '303', '300', '284', '289', '337', '308', '300', '288', '333', '321', '373', '301', '272', '288', '322', '318', '314', '321', '297', '299', '306', '312', '325', '334', '390', '339', '317', '343', '336', '357', '366', '383', '379', '355', '342', '369', '362', '359', '360', '380', '388', '393', '362', '347', '335', '322', '334', '313', '309', '303', '304', '326', '354', '364', '360', '343', '335', '343', '366', '318', '347', '326', '327', '329', '334', '347', '364', '346', '338', '337', '325', '304', '285', '298', '310', '316', '311', '321', '323', '360', '351', '337', '345', '372', '367', '356', '331', '308', '323', '327', '312', '300', '296', '305', '323', '338', '328', '319', '315', '315', '313', '316', '314', '312', '354', '317', '323', '324', '352', '360', '342', '333', '348', '335', '320', '321', '326', '327', '323', '303', '318', '308', '307', '302', '293', '304', '322', '302', '307', '304', '302', '287', '290', '306', '299', '297', '284', '289', '287', '316', '292', '291', '307', '300', '318', '302', '309', '320', '296', '293', '291', '287', '293', '287', '296', '293', '297', '287', '296', '296', '290', '287', '290', '290', '302', '298', '301', '297', '302', '290', '297', '288', '288', '299', '319', '311', '300', '302', '305', '294', '293', '288', '288', '289', '291', '286', '282', '280', '287', '279', '294', '345', '344', '292', '317', '296', '287', '288', '285', '291', '300', '298', '288', '288', '287', '275', '282', '288', '270', '272', '283', '284', '284', '295', '290', '279', '290', '287', '276', '289', '286', '295', '301', '287', '332', '305', '304', '275', '263', '266', '256', '257', '269', '258', '257', '273', '291', '277', '272', '280', '266', '269', '256', '282', '274', '308', '295', '288', '331', '290', '295', '283', '288', '285', '267', '274', '279', '300', '290', '293', '308', '285', '288', '279', '270', '281', '297', '296', '275', '255', '242', '239', '242', '269', '275', '278', '286', '276', '269', '283', '290', '317', '286', '287', '282', '273', '289', '322', '352', '268', '290', '311', '277', '256', '246', '255', '252', '265', '269', '265', '278', '272', '273', '302', '287', '284', '316', '318', '310', '280', '288', '293', '291']
#Los número están en formato string, por lo que los convertimos a enteros
array = [int(n) for n in array]
#Nos creamos un rango de fechas
months = pd.date_range("01-01-2020", "31-12-2020")
plt.plot(months, array)
plt.ylabel('Ozone Madrid')
plt.xlabel('Months')
plt.show()
Departure: See how I've also turned all numbers into integers so that matplotlib I can represent it perfectly.