How to plot the boxplot of the columns in one loop?
Question:
I have the following columns in a data-frame df:
columns = ['temperature','humidity' ,'pressure','rain' ,'lightavgw/o0' ,'lightmax','moisture']
What I want is to create a loop where I can plot the boxplot of all the columns through a single loop.
I tried the following code:
columns = ['temperature','humidity' ,'pressure','rain' ,'lightavgw/o0' ,'lightmax','moisture']
for col in columns:
plt.boxplot(df[col])
Answers:
To plot the figure for each column, use plt.figure() inside the loop
columns = ['temperature','humidity' ,'pressure','rain' ,'lightavgw/o0','lightmax','moisture']
for col in columns:
plt.figure() # plots figure for each iteration
plt.boxplot(df[col])
How to plot each item in different frame in cycle?
I have the following columns in a data-frame df:
columns = ['temperature','humidity' ,'pressure','rain' ,'lightavgw/o0' ,'lightmax','moisture']
What I want is to create a loop where I can plot the boxplot of all the columns through a single loop.
I tried the following code:
columns = ['temperature','humidity' ,'pressure','rain' ,'lightavgw/o0' ,'lightmax','moisture']
for col in columns:
plt.boxplot(df[col])
To plot the figure for each column, use plt.figure() inside the loop
columns = ['temperature','humidity' ,'pressure','rain' ,'lightavgw/o0','lightmax','moisture']
for col in columns:
plt.figure() # plots figure for each iteration
plt.boxplot(df[col])
How to plot each item in different frame in cycle?