Plotting linear regression with Date/Week on x axis using Seaborn


5 weeks ago


332 time



my company uses some weird date notation, which has this format: [2 digits week number][2 digit working hours]. Both groups use leading zeros. So the data could like: 0801, 0802, 0901, 0902, 0903, 1001, 1002, 1003

For each of this "dates" there is a scoring. This is just regular floating numbers from 0 to 100.

Example (csv):


Here is some sample data


With this data I want to create a scatter plot including a linear regression!

I was able to create this regression using Seaborn (which uses matplotlib). Yet some binning is happening here:

Linear Regression

The code I’m using:

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df = pd.read_csv('test.csv')
sns.regplot('wxxhxx', 'scoring', df)

When using Seaborn’s strip plot the data looks "nicer", yet there is no regression here: enter image description here


sns.stripplot(x='wxxhxx', y='scoring', data=df)

My Problem

Is there any way to combine the looks of these two methos (regplot and stripplot). I would like to have a regression within the strip plot, OR I would like the to get a equidistant distribution (like in strip plot) of the x values within the regplot, so that the values don’t stack.

Thanks for any advice!

0 answers