Home > Mobile >  Seaborn: How to plot multiple series to show their relation
Seaborn: How to plot multiple series to show their relation

Time:12-29

I have a pandas dataframe with this structure:

df_values

X     |  Y_A  | Y_B
10    |  100  | 110
11    |  200  | 220

I would like to plot a trend that focuses on the relationship between Y_A and Y_B, to verify visually follow a similar function.

Currently, by trying sns.relplot(data=df_values) I have the X values plotted as well (I don't necessarily need them plotted as a line), any tips on how Seaborn could be used with this dataset for he purpose of showing the relationships between the trends? I am new to Seaborn so any ideas are very welcome!

CodePudding user response:

Just divide one by the other and use that as your y

import pandas as pd
import seaborn as sns

df = pd.DataFrame({'X':[1,2,3,4],'Y_A':[100,200,300,400],'Y_B':[110,220,330,440]})
df['y_ratio'] =  df['Y_A'] / df['Y_B']
sns.lineplot(data=df, x='X',y='y_ratio');

enter image description here

  • Related