[英]How to draw multiple lines with Seaborn?
I am trying to draw a plot with two lines.我正在尝试用两条线绘制 plot 。 Both with different colors.两者都具有不同的 colors。 And different labels.以及不同的标签。 This is what I have come up with.这就是我想出的。
This is code that I have written.这是我写的代码。
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
data1 = pd.read_csv("/content/drive/MyDrive/Summer-2020/URMC/training_x_total_data_ones.csv", header=None)
data2 = pd.read_csv("/content/drive/MyDrive/Summer-2020/URMC/training_x_total_data_zeroes.csv", header=None)
sns.lineplot(data=data1, color="red")
sns.lineplot(data=data2)
What am I doing wrong?我究竟做错了什么?
This is how my dataset looks like这就是我的数据集的样子
Try specifying the x
and y
of the call to sns.lineplot
?尝试指定调用sns.lineplot
的x
和y
吗?
import pandas as pd
import numpy as np
import seaborn as sns
x = np.arange(10)
df1 = pd.DataFrame({'x':x,
'y':np.sin(x)})
df2 = pd.DataFrame({'x':x,
'y':x**2})
sns.lineplot(data=df1, x='x', y='y', color="red")
sns.lineplot(data=df2, x='x', y='y')
Without doing so, I get a similar plot as yours.如果不这样做,我会得到与您类似的 plot。
So, I just added another color in the second line and that seemed to work.所以,我只是在第二行添加了另一种颜色,这似乎有效。
import random
import numpy as np
import seaborn as sns
mu, sigma = 0, 0.1
s = np.random.normal(mu, sigma, 100)
mu1, sigma1 = 0.5, 1
t = np.random.normal(mu1, sigma1, 100)
sns.lineplot(data= s, color = "red")
sns.lineplot(data= t, color ="blue")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.