I want to create a smoothed line chart using matplotlib and seaborn.
This is my dataframe df:
hour direction hourly_avg_count
0
Try adding a dummy unit column. The first parts is to create some synthetic data, so please ignore.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
df1 = pd.DataFrame({
"hour":range(24),
"direction":1,
"hourly_avg_count": np.random.randint(25,28,size=24)})
df2 = pd.DataFrame({
"hour":range(24),
"direction":2,
"hourly_avg_count": np.random.randint(25,28,size=24)})
df = pd.concat([df1,df2],axis=0)
df['unit'] = 'subject'
plt.figure()
sns.tsplot(data=df, time='hour', condition='direction',
unit='unit', value='hourly_avg_count')