简体   繁体   中英

How to make several plots with seaborn?

What I want:
I want to plot around 8 density(violin) plots(all in separate graphs) using a function, however when I run I get either a single plot with all 8 features or 8 different plots of the same feature.
How to plot different plots on different graphs using a function?

My current codes:

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

Without knowing anything about visualise_univariate_feature it's impossible to give a definitive answer.

However you might try

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM