简体   繁体   中英

Seaborn: How to plot multiple series to show their relation

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!

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');

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM