I'm experiencing crowding on my x-axis when using lineplot in seaborn.
I initially plotted the data with the following:
import pandas as pd
import matplotlib
matplotlib.use('TkAgg')
import seaborn as sns
for state in states_list:
starting_point = state_covid_data[(state_covid_data.cases > 9) & (state_covid_data.state == state)]
plot = sns.lineplot(data=starting_point, x='date', y='cases')
plot
Here is the output: https://i.stack.imgur.com/eeh34.png
To try and fix the crowding, I adjusted my code as follows from the recommendation in this answer:
for state in states_list:
starting_point = state_covid_data[(state_covid_data.cases > 9) & (state_covid_data.state == state)]
plot = sns.lineplot(data=starting_point, x='date', y='cases')
for ind, label in enumerate(plot.get_xticklabels()):
if ind % 10 == 0: # every 10th label is kept
label.set_visible(True)
else:
label.set_visible(False)
plot
This resulted in only one date showing up on my x-axis: https://i.stack.imgur.com/Md8x1.png
Any recommendations how to to fix this? Ideally I would like to select which ticks appear. Even better would to be able to substitute certain ticks for my own values.
Thanks for your time!