【发布时间】:2015-09-29 10:58:32
【问题描述】:
我的目标是创建一个简单的函数,用已绘制变量的名称为图形命名。
到目前为止我有:
def comparigraphside(rawvariable, filtervariable, cut):
variable = rawvariable[filtervariable > 0]
upperbound = np.mean(variable) + 3*np.std(variable)
plt.figure(figsize=(20,5))
plt.subplot(121)
plt.hist(variable[filtervariable <= cut], bins=20, range=(0,upperbound), normed=True)
plt.title("%s customers with filter less than or equal to %s" % (len(variable[filtervariable <= cut]), cut))
plt.subplot(122)
plt.hist(variable[filtervariable > cut], bins=20, range=(0,upperbound), normed=True)
plt.title("%s customers with filter greater than %s" % (len(variable[filtervariable > cut]), cut));
它在哪里:
plt.title("%s customers with filter less/greater...")
我很想说:
plt.title("%s customers with %s less/greater...")
目前我能想到的唯一解决方案是制作一个变量字典,我想避免这种情况。非常感谢任何和所有的帮助。
【问题讨论】:
标签: python matplotlib