I want to plot a Pandas dataframe's values on y-axis and dates on x-axis, and control the xticks and their frequency.
datevalue is the dataframe and it looks like this:
datevalue.head()
Date Month Value
0 2016-01-01 January 2094.70
1 2016-01-02 January 2041.90
2 2016-01-03 January 2133.34
3 2016-01-04 January 2023.25
4 2016-01-05 January 2023.98
To plot the values on the respective dates, I guess scatterplot would be good for this purpose. I initiate the figure and plot the scatterplot:
scatter_datevalue = plt.figure(figsize=(15,5))
scatter_datevalue = sns.set(style="whitegrid", font_scale=.6)
scatter_datevalue = sns.scatterplot(x="Date", y="value", data=datevalue)
scatter_datevalue.set(xlim=("2016-01-01", "2016-12-31"))
This gives me the following figure:
However, the xtick labels (is this the correct thing to call them?) show only the twelve months. Instead, I want to show the dates, and be able to try different frequencies (steps?) for the ticks, for example show a tick for every day, or every 7 days or so.
How can I do this? I've tried everything I've found but couldn't get it right.
Bonus question: as there is the "Month" column in the same dataframe, I'd like to show the month names below the date ticks (when a new month starts) if that is possible.