如何用seaborn制作几个地块?

时间:2017-04-11 07:03:45

标签: python matplotlib plot visualization seaborn

我想要的是什么:
我想使用一个函数绘制8个密度(小提琴)图(均在单独的图中),但是当我运行时,我得到一个包含所有8个特征的图或具有相同特征的8个不同图。 如何使用函数在不同的图形上绘制不同的图?

我目前的代码:

#CODE-1

#feature: a list of 8 features that i want to visualise
#visualise_univariate_feature: a function that plots a seaborn violin plot
#this code produces 8 plots but all on the same feature from the list(the last element of the list)

for i in range(9):
plt.figure(i)
for feature in features:
    display(visualise_univariate_feature(x=feature))

#CODE-2 

#This code produces 1 plot with 8 features all together
for feature in features:
   display(visualise_univariate_feature(x=feature))

1 个答案:

答案 0 :(得分:1)

在不了解visualise_univariate_feature的情况下,无法给出明确的答案。

但是你可以试试

for i, feature in enumerate(features):
    plt.figure(i+1)
    display(visualise_univariate_feature(x=feature))