减少seaborn时间序列图的线宽

时间:2017-08-07 06:49:35

标签: python matplotlib seaborn

factory

在上图中,如果我将比例指定为0.5,则会减小线宽,但不会减小置信区间线的宽度。有没有办法减少置信区间线的宽度?

2 个答案:

答案 0 :(得分:4)

您可以获得第一行的线宽并将其设置为因子图的所有其他行:

function showMembers(){

    // set the parameters you what
    var data = { param1 : "param1", param2 : "param2"}

    $.ajax({
        //set correct url
        url: localhost/path/showAllMembers,
        type: 'post',
        data: data, 

        success: function(response){

            // response will contain every object you added in model object, so in this case list
            $.each(response.list, function(index, value){
                  // do whatever you want with your data
            });
        }); 
}

enter image description here

您可以为周期中的每一行设置线宽:

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

输出:

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

粗线是根据保密间隔。

将线宽设置为5后,所有线都变为相同:

enter image description here

答案 1 :(得分:3)

如果要更改绘图中所有直线(轴除外)的宽度,只需通过seaborns "lines.linewidth"功能更改matplotlib rcparam中的参数set即可。只需在rc={"lines.linewidth":0.7}的调用中添加sns.set作为参数即可。同样,您也可以更改所有(或至少大多数)默认设计选项。

示例:

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