Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python n+;=1英寸plt.子批次平均值_Python_Matplotlib_Seaborn - Fatal编程技术网

Python n+;=1英寸plt.子批次平均值

Python n+;=1英寸plt.子批次平均值,python,matplotlib,seaborn,Python,Matplotlib,Seaborn,我不明白下面的n+=1变量是如何将distplot可视化为3列的 n=0 for x in ['Age', 'Annual Income (k$)', 'Spending Score (1-100)']: n +=1 plt.subplot(1,3,n) plt.subplots_adjust(hspace=0.5,wspace = 0.5) sns.distplot(df[x], bins = 20) plt.title('Displot of {}'.

我不明白下面的n+=1变量是如何将distplot可视化为3列的

n=0
for x in ['Age', 'Annual Income (k$)', 'Spending Score (1-100)']:
    n +=1
    plt.subplot(1,3,n)
    plt.subplots_adjust(hspace=0.5,wspace = 0.5)
    sns.distplot(df[x], bins = 20)
    plt.title('Displot of {}'.format(x))
plt.show()

请参见distplot的附图

plt的第三个参数。子图表示索引。这可能对您有所帮助:

其中一个描述的子批次的位置

三个整数(nrows、ncols、index)。子批次将在包含nrows行和ncols列的网格上占据索引位置。索引从左上角的1开始,向右增加。索引也可以是两个元组,指定子批次的(第一个、最后一个)索引(基于1,包括最后一个),例如,图add_子批次(3,1,(1,2))生成一个子地块,该地块横跨地物的上2/3


一个3位数的整数。这些数字被解释为三个单位数的整数,即fig.add_子批次(235)与fig.add_子批次(2,3,5)相同。请注意,只有在子批次不超过9个的情况下,才可以使用它。”

作为旁注,您可以在enumerate(['Age',Year Income(k$)中为n,x枚举-
“,”消费分数(1-100)]:
这能回答你的问题吗?