odbhut.shei.chhele
odbhut.shei.chhele

Reputation: 6264

How to draw multiple lines with Seaborn

I am trying to draw a plot with two lines. Both with different colors. And different labels. This is what I have come up with.

enter image description here

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?

Edit

This is how my dataset looks like

enter image description here

Upvotes: 3

Views: 11798

Answers (2)

learning_to_code
learning_to_code

Reputation: 69

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")

enter image description here

Upvotes: 3

Tom
Tom

Reputation: 8800

Try specifying the x and y of the call to sns.lineplot?

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

enter image description here

Without doing so, I get a similar plot as yours.

Upvotes: 1

Related Questions