title: Matplotlib - plot dates in days and hours (x axis) vs values (y axis)
body: <p>I have an <code>xlsx</code> file that contains two columns. The first is the timestamp (DT-Index) like this (18.01.2012  06:00:00), and the second contains normal values.</p>
  <p>I have 1 year of timestamps sliced into 24 hours a day which is a total of 8736 value. Now I want to plot these data like shown in the following  picture.<a href="https://i.stack.imgur.com/TF2Zd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TF2Zd.jpg" alt="enter image description here" /></a></p>
  <pre><code>import pandas as pd
  import matplotlib.pyplot as plt
  import matplotlib.dates as mdates
  import numpy as np
  
  
  test = ['Monday - 00', 'Monday - 01', 'Monday - 02',
              'Monday - 03', 'Monday - 04', 'Monday - 05', 'Monday - 06', 'Monday - 07', 'Monday - 08', 'Monday - 09', 'Monday - 10',
               'Monday - 11', 'Monday - 12', 'Monday - 13', 'Monday - 14', 'Monday - 15', 'Monday - 16', 'Monday - 17', 'Monday - 18',
                'Monday - 19', 'Monday - 20', 'Monday - 21', 'Monday - 22', 'Monday - 23' ,'Tuesday - 00', 'Tuesday - 01', 'Tuesday - 02', 'Tuesday - 03', 'Tuesday - 04', 'Tuesday - 05', 'Tuesday - 06', 'Tuesday - 07', 
  'Tuesday - 08', 'Tuesday - 09', 'Tuesday - 10', 'Tuesday - 11', 'Tuesday - 12', 'Tuesday - 13', 'Tuesday - 14'
  , 'Tuesday - 15', 'Tuesday - 16', 'Tuesday - 17', 'Tuesday - 18', 'Tuesday - 19', 'Tuesday - 20', 'Tuesday - 21',
  'Tuesday - 22', 'Tuesday - 23', 
  'Wednesday - 00', 'Wednesday - 01', 'Wednesday - 02', 'Wednesday - 03', 'Wednesday - 04', 'Wednesday - 05', 'Wednesday - 06', 'Wednesday - 07',
  'Wednesday - 08', 'Wednesday - 09', 'Wednesday - 10', 'Wednesday - 11', 'Wednesday - 12', 'Wednesday - 13', 'Wednesday - 14', 'Wednesday - 15',
   'Wednesday - 16', 'Wednesday - 17', 'Wednesday - 18', 'Wednesday - 19', 'Wednesday - 20', 'Wednesday - 21', 'Wednesday - 22', 'Wednesday - 23',
    'Thursday - 00', 'Thursday - 01', 'Thursday - 02', 'Thursday - 03', 'Thursday - 04', 'Thursday - 05', 'Thursday - 06', 'Thursday - 07'
    , 'Thursday - 08', 'Thursday - 09', 'Thursday - 10', 'Thursday - 11', 'Thursday - 12', 'Thursday - 13', 'Thursday - 14', 'Thursday - 15',
     'Thursday - 16', 'Thursday - 17', 'Thursday - 18', 'Thursday - 19', 'Thursday - 20', 'Thursday - 21', 'Thursday - 22', 'Thursday - 23',
      'Friday - 00', 'Friday - 01', 'Friday - 02', 'Friday - 03', 'Friday - 04', 'Friday - 05', 'Friday - 06', 'Friday - 07', 'Friday - 08',
       'Friday - 09', 'Friday - 10', 'Friday - 11', 'Friday - 12', 'Friday - 13', 'Friday - 14', 'Friday - 15', 'Friday - 16', 'Friday - 17',
        'Friday - 18', 'Friday - 19', 'Friday - 20', 'Friday - 21', 'Friday - 22', 'Friday - 23', 'Saturday - 00', 'Saturday - 01', 'Saturday - 02',
         'Saturday - 03', 'Saturday - 04', 'Saturday - 05', 'Saturday - 06', 'Saturday - 07', 'Saturday - 08', 'Saturday - 09', 'Saturday - 10', 
         'Saturday - 11', 'Saturday - 12', 'Saturday - 13', 'Saturday - 14', 'Saturday - 15', 'Saturday - 16', 'Saturday - 17', 'Saturday - 18',
          'Saturday - 19', 'Saturday - 20', 'Saturday - 21', 'Saturday - 22', 'Saturday - 23', 'Sunday - 00', 'Sunday - 01', 'Sunday - 02',
           'Sunday - 03', 'Sunday - 04', 'Sunday - 05', 'Sunday - 06', 'Sunday - 07', 'Sunday - 08', 'Sunday - 09', 'Sunday - 10',
            'Sunday - 11', 'Sunday - 12', 'Sunday - 13', 'Sunday - 14', 'Sunday - 15', 'Sunday - 16', 'Sunday - 17', 'Sunday - 18',
             'Sunday - 19', 'Sunday - 20', 'Sunday - 21', 'Sunday - 22', 'Sunday - 23',];
  
  
  
  
  df = pd.read_excel('file.xlsx' , sheet_name=&quot;x&quot;)
  blue = df.loc[df['DT-Index'].map(lambda date: date.month == 12 or date.month == 1 or date.month == 2)]
  red = df.loc[df['DT-Index'].map(lambda date: date.month == 3 or date.month == 4 or date.month == 10 or date.month == 11)]
  purple = df.loc[df['DT-Index'].map(lambda date: date.month == 5 or date.month == 9)]
  green = df.loc[df['DT-Index'].map(lambda date: date.month == 6 or date.month == 7 or date.month == 8)]
  
  xB =  list(blue['DT-Index'])
  yB = list(blue['values'])
  
  xR =  list(red['DT-Index'])
  yR = list(red['values'])
  
  xP =  list(purple['DT-Index'])
  yP = list(purple['values'])
  
  xG =  list(green['DT-Index'])
  yG = list(green['values'])
  
  def mittelwerte(dic):
    for val in dic.keys():
        dic[val] = int(sum(dic[val]) / len(dic[val]))
    return dic;
  
  def appendToDict(x , y):
    data = dict()
    xAF = list(map(lambda date: date.to_pydatetime() , x))
    for i in range(len(x)):
        day = xAF[i].strftime(&quot;%A - %H&quot;)
        if day in data.keys():
            data[day].append(y[i])
        
        else :
            data[day] = [y[i]]
    return sortDict(mittelwerte(data) , test)
  
  def sortDict(dic , keys):
    data = dict.fromkeys(keys);
    for data1 in data.keys():
        for data2 in dic.keys():
            if(data1 == data2):
                data[data1] = dic[data2]
    return data;
  
  
  
  
  dataB = appendToDict(xB , yB)
  dataR = appendToDict(xR , yR)
  dataP = appendToDict(xP , yP)
  dataG = appendToDict(xG , yG)
  
  # my_xticks = ['Monday','Tuesday','Wednesday','Thursday','Friday' , 'Saturday' , 'Sunday']
  # plt.xticks(list(dataB.keys()), my_xticks)
  
  plt.plot(list(dataB.keys()), list(dataB.values()), color='#3074bb')
  plt.plot(list(dataR.keys()), list(dataR.values()), color='#bb3530')
  plt.plot(list(dataP.keys()), list(dataP.values()), color='#a630bb')
  plt.plot(list(dataG.keys()), list(dataG.values()), color='#30bb40')
  
  plt.ylabel('Y Values')
  plt.legend()
  plt.show()
  
  
  </code></pre>
  <p>The problem I face is that there are lots of days, and when I try to plot them like this, I get Monday 20 times and more. How can I achieve the solution shown in the picture?</p>
  <p>---------------Updates--------------</p>
  <p>I have tried to achieve the solution in the first picture but I get a problem in the x-axis as the following picture shows it plots the whole list what should i do to achieve the wanted result in the first picture <a href="https://i.stack.imgur.com/4CjsB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4CjsB.png" alt="matplotlib" /></a></p>