2017-08-07 8 views

答えて

3

あなたM AY最初のラインの線幅を取得し、因子プロットの他のすべての行のためにそれを設定します。

import seaborn as sns 
import matplotlib.pylab as plt 
sns.set(style="ticks") 
exercise = sns.load_dataset("exercise") 
g = sns.factorplot(x="time", y="pulse", hue="kind", data=exercise, scale=.5) 
lw = g.ax.lines[0].get_linewidth() # lw of first line 
plt.setp(g.ax.lines,linewidth=lw) # set lw for all lines of g axes 

plt.show() 

enter image description here

そして、あなたは、サイクル内のすべての行の線幅を設定することができます。

for l in g.ax.lines: 
    print(l.get_linewidth()) 
    plt.setp(l,linewidth=5) 

出力:

1.575 
3.15 
3.15 
3.15 
1.575 
3.15 
3.15 
3.15 
1.575 
3.15 
3.15 
3.15 

太字の行は機密間隔によるものです。

5に設定された線幅の後、すべての行が同じになった:

enter image description here

1

プロット内のすべての線(軸を除く)の幅を変更したい場合は、matplotlib rcparamのパラメータ"lines.linewidth"をseaborns set関数で単純に変更できます。 sns.setの呼び出しでパラメータとしてrc={"lines.linewidth":0.7}を追加するだけです。同様に、デフォルトデザインオプションのすべて(または少なくともほとんど)を変更することもできます。

例:

import seaborn as sns 
sns.set(style="ticks", rc={"lines.linewidth": 0.7}) 
exercise = sns.load_dataset("exercise") 
g = sns.factorplot(x="time", y="pulse", hue="kind", data=exercise) 

これは、次のプロットをもたらす:

enter image description here

rc={"lines.linewidth":0.7}なし)元プロットであった:

enter image description here

関連する問題