title: Lowering the x axis value density for dates on a seaborn line plot
body: <p>Pretty new to python and programming in general so bear with me please. I have a data set imported from a .csv file and I'm trying to plot a column of values (y axis) by date (x axis) over a 1 year period but the problem is that the dates are way too dense and I can't for the life of me figure out how to space them out or modify how they're defined. Here's the code I'm working with:</p>
  <pre><code>import pandas as pd
  import numpy as np
  import seaborn as sns
  import matplotlib.pyplot as plt
  import matplotlib as mpl
  from scipy import stats
  import cartopy.crs as ccrs
  import cartopy.io.img_tiles as cimgt
  
  df = pd.read_csv('Vanuatu Earthquakes 2018-2019.csv')
  </code></pre>
  <p>and here's the line plot code:</p>
  <pre><code>plt.figure(figsize=(15, 7))
  ax = sns.lineplot(x='date', y='mag', data=df).set_title(&quot;Earthquake magnitude May 2018-2019&quot;)
  
  plt.xlabel('Date')
  plt.ylabel('Magnitude (Mw)')
  plt.savefig('EQ mag time')
  </code></pre>
  <p>This currently gives me this line plot:
  <img src="https://i.stack.imgur.com/qiVzW.png" alt="1" /></p>
  <p>Currently I want to do it by something like a small tick for each day and a larger tick + label for the beginning of each week. Doesn't have to be exactly that but I'm mostly looking to just decrease the density. I've looked at loads of posts on here but none of them seem to work for my situation so any help would be greatly appreciated.</p>
  <p>[Update]</p>
  <p>Got the dates working as per Konqui's advice below and my code now looks like this:</p>
  <pre><code>time = pd.date_range(start = '01-05-2018',
                       end = '01-05-2019',
                       freq = 'D')
  df = pd.DataFrame({'date': list(map(lambda x: str(x), time)),
                     'mag': np.random.random(len(time))})
  
  plt.figure(figsize=(15, 7))
  df['date'] = pd.to_datetime(df['date'], format = '%Y-%m')
  ax = sns.lineplot(x='date', y='mag', data=df).set_title(&quot;Earthquake magnitude May 2018-2019&quot;)
  ax.xaxis.set_major_locator(md.WeekdayLocator(byweekday = 1))
  ax.xaxis.set_major_formatter(md.DateFormatter('%Y-%m-%d'))
  plt.setp(ax.xaxis.get_majorticklabels(), rotation = 90)
  ax.xaxis.set_minor_locator(md.DayLocator(interval = 1))
  plt.xlabel('Date')
  plt.ylabel('Magnitude (Mw)')
  </code></pre>
  <p>which gives me an error message: <code>AttributeError: 'Text' object has no attribute 'xaxis'</code>. Any thoughts?</p>