2017-08-07 17 views
2
import seaborn as sns 
sns.set(style="ticks") 
exercise = sns.load_dataset("exercise") 
g = sns.factorplot(x="time", y="pulse", hue="kind", data=exercise) 

在上面的图中,如果我将比例指定为0.5,它会减小线宽而不是置信区间线的宽度。有减少置信区间线宽度的方法吗?减小seaborn时间序列的线宽图

回答

3

优米唉得到第一线的线宽,并设置它的因素情节的所有其他线路:

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中通过seaborns set函数更改参数"lines.linewidth"即可。只需在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