'Define aesthetics of seaborn plot, line colors and type of line

Right now I have a data frame with 4 columns: "CTN (code of product)", "Date", "variable", "value (the quantity)". In total there are 4 different products from january 2019 to february 2022. The column variable has 2 categories: "Quantity" and "Quantity Adjusted" (each product counts with both).

Data frame

Right now I am plotting the evolution of the four products, but distinguishing between Quantity and Quantity Adjusted (The second one is a correction of the first one). Is there a way to put the same color for the same product but solid line for "Quantity" and dash line for "Quantity Adjusted"?. Below is the code I have right now and the plot that I am obtaining. (it looks messy with 8 different colors, so I just want 4 colors)

sns.relplot(x='Date', y='value', hue=dfm[['CTN', 'variable']].apply(tuple, axis=1),legend=False,estimator=None, kind="line",marker="o", height=4.27, aspect=10/4.27, data=dfm)
sns.set_style("white")
plt.legend(labels=set(dfm[['CTN', 'variable']].apply(tuple, axis=1)),loc='upper left', title='SKU')
plt.xticks(np.arange(0, 39, 2))
plt.xticks(rotation=90)
plt.ylabel('Units Sold (00)')
plt.gca().axes.yaxis.set_ticklabels([])
plt.show();

Current Plot

Thanks a lot!



Sources

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

Source: Stack Overflow

Solution Source