'How to change default x axis range display

Im fairly new to python and am having some issues with scatter plot. The data is from 2000 to 2002 and the x access out label values are overcrowding. Ive tried a few ways to adjust the range but I dont want to reduce the the number of points only the label values that are displayed. Is there anyone that could provide some guidance? Here is my code:

 *from google.colab import output
 Fig_2_Scatter_Graph_Number_Messages = True #@param {type:"boolean"}
 from matplotlib import pyplot as plt
 import numpy as np
 num_message_df.plot.scatter(x = 'date_sent', y = 'message_count')
 plt.rcParams["figure.figsize"] = (30,20)
 plt.title("Number of Messages each day by Date")
 plt.xlabel("Date Sent")
 plt.ylabel("Number of Messages")
 plt.xticks(rotation=90) 
 plt.legend(loc=1)
 output.clear()*


Solution 1:[1]

You could reset the minor tick axis to match the major (accessed as plt.gca().get_xticks(), and then slice the same to set as your major axis. Add the following lines:

plt.gca().set_xticks(plt.gca().get_xticks(), minor = True)
plt.gca().set_xticks(plt.gca().get_xticks()[0::3], minor = False) #take every third label

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Professor Pantsless