def factor_plot(dataFrame, factors, prediction, color="Set3"):
# First, plot the total for each factor. Then, plot the total for each
# factor for the prediction variable (so in a conversion example, how
# many people converted, revenue per country, etc.)
# These refer to the rows and columns of the axis numpy array; not the
# data itself.
row = 0
column = 0
sns.set(style="whitegrid")
# TODO: Set the width based on the max number of unique
# values for the factors.
plots = plt.subplots(len(factors), 2, figsize=(8,12))
# It should
for factor in factors:
sns.countplot(x=factor, palette="Set3", data=dataFrame,
ax=plots[1][row][column])
# Then print the total for each prediction
sns.barplot(x=factor, y=prediction, data=dataFrame,
ax=plots[1][row][column+1])
row += 1
plt.tight_layout() # Need this or else plots will crash into each other
评论列表
文章目录