Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

seaborn scatterplot is plotting more dates than exist in the original data

Tags:

python

seaborn

My dataset contains data for 2018. I tried plotting a simple scatterplot, and for some reason seaborn plots from 2000 - 2018. I haven't found a solution for this.

seaborn lineplot works.

Matplotlib scatter also works with no issue.

Code:

plt.figure(figsize = (7,7), dpi = 200)
sns.scatterplot(x = df["Date"].values,
           y = df["values"].values)
plt.show()

enter image description here

like image 795
Alexis Drakopoulos Avatar asked Dec 28 '18 20:12

Alexis Drakopoulos


1 Answers

You can manually set the limits of the x axis by using .set() on the plot.

ax = sns.scatterplot(x = df["Date"].values, y = df["values"].values)
ax.set(xlim = ('2018-01-01', '2018-12-31'))
like image 151
Jordan Avatar answered Oct 17 '22 08:10

Jordan