I faced a warning message when trying to rotate xticks of seaborn.lineplot.
At first, I tried to run set_ticks, but ax doesn't seem to have this function. I also checked FixedLocator, but haven't figured out how to use it.
Can anyone teach me how to remove this warning message?
Environment
- Python 3.12.1
- matplotlib 3.8.2
- pandas 2.2.0
- seaborn 0.13.2
Sample Data
Code
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
data: pd.DataFrame = pd.read_csv("DailyDelhiClimateTest.csv",
parse_dates=["date"], index_col="date")
ax: plt.Axes = sns.lineplot(data=data)
ax.set_xticklabels(ax.get_xticklabels(), rotation=45)
Warning Message
UserWarning: set_ticklabels() should only be used with a fixed number of ticks, i.e. after set_ticks() or using a FixedLocator.
ax.set_xticklabels(ax.get_xticklabels(), rotation=45)