我想在所有不同的图形上可视化10个不同的东西。
figure, ((ax1, ax2), (ax3, ax4), (ax5, ax6), (ax7, ax8), (ax9, ax10)) = plt.subplots(nrows=2, ncols=5)
figure.set_size_inches(17,8)
for i, age_g in enumerate(age_cat):
group = total_usage_df.loc[(total_usage_df.age_group == age_g) & (total_usage_df.day_of_week <= 4)]
sns.distplot(group.rent_hour, ax=)
在最后一行,我不知道如何从1〜10循环遍历所有斧头。
我希望传递[ax1,ax2等...]的列表,以便我可以遍历它们:
lst = [ax1, ax2, ax3, ax4, ax5, ax6, ax7, ax8, ax9, ax10]
figure, (lst) = plt.subplots(nrows=2, ncols=5)
figure.set_size_inches(17,8)
for i, age_g in zip(lst, age_cat):
group = total_usage_df.loc[(total_usage_df.age_group == age_g) & (total_usage_df.day_of_week <= 4)]
sns.distplot(group.rent_hour, ax=i)
类似的东西,但是输出:
NameError: name 'ax1' is not defined
如何遍历每个ax1〜ax10?
答案 0 :(得分:1)
实际上,您应该使用- (void)textViewDidChange:(UITextView *)textView
{
CGFloat minHeight = 30;
CGFloat maxHeight = 150;
CGFloat height = ceil([textView.text sizeWithAttributes:@{NSFontAttributeName : textView.font}].height);
if(height < minHeight){
height = minHeight;
}else if (height > maxHeight){
height = maxHeight;
}
self.textViewHeightConstraint.constant = height;
}
或ravel
:
flatten