2016-04-16 16 views
5

Python ve Seaborn ile factorplot() yöntemini kullanarak aşağıdaki çizim yapıyorum. Çizgi stilini efsaneyi sağdaki çizgi rengine göre değiştirmek için bir efsane olarak kullanmak mümkün mü?Python Seaborn Matplotlib ayar çizgisi stil efsanesi olarak

graycolors = sns.mpl_palette('Greys_r', 4) 
g = sns.factorplot(x="k", y="value", hue="class", palette=graycolors, data=df, linestyles=["-", "--"]) 

enter image description here Ayrıca ben rengini benim factorplot yönteminde = "siyah" parametresi kullanılarak siyah renkte iki hattını çalışıyorum ama bu bir özel durum "factorplot() beklenmedik bir anahtar kelime argüman 'renk' var ". Her iki çizgiyi aynı renkte nasıl boyayabilirim ve sadece stil stiliyle nasıl ayırabilirim?

Ben matplotlib gibi efsanede çizgi stilini koymak için çalışırken bir çözüm arıyorsanız edilmiş

cevap

3

Teşekkür ederim, ama henüz Seaborn içinde bunun nasıl bulamadı. Ancak, ben markers farklı kullanmış efsanede veriler açıklığa kavuşturmak:

import seaborn as sns 
import numpy as np 
import pandas as pd 

# creating some data 
n = 11 
x = np.linspace(0,2,n) 
y = np.sin(2*np.pi*x) 
y2 = np.cos(2*np.pi*x) 
df=pd.DataFrame({'x':np.append(x, x),'y':np.append(y, y2),'class':np.append(np.repeat('sin',n),np.repeat('cos',n))}) 

# plot the data with the markers 
# note that I put the legend=False to move it up (otherwise it was blocking the graph) 
g=sns.factorplot(x="x",y="y",hue="class",palette=graycolors, data=df, linestyles=["-", "--"],markers=['o','v'], legend=False) 
# placing the legend up 
g.axes[0][0].legend(loc=1) 
#showing graph 
plt.show() 

the graph

+0

Müthiş, teşekkür. Hala benim için uygun –