'Seaborn line across scatterplot

I have a seaborn scatterplot across categories (y-axis) with time on the x-axis:

z=sns.scatterplot(data=df], x="transaction_date", y="product_name", hue="source_of_business",s=100)

What's the best way to add a line across each date category combination like below



Solution 1:[1]

This can be done by setting up a line chart using data frames extracted by product name.

ax = sns.scatterplot(data=df, x="transaction_date", y="product_name", hue="source_of_business", s=100)
for c in df['product_name'].unique():
    dfq = df.query('product_name == @c').reset_index()
    sns.lineplot(data=dfq, x='transaction_date',y='product_name', color='black', ax=ax) 

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 r-beginners