2017-04-01 11 views
1

私は、matplotlibの関数で変数を呼び出そうとしていますが、エラーが出ます。多分それは不可能です。Matplotlibヒストグラムのタイトル

sigma = float(some number) 
ax1.hist(population) 
ax1.set_title('blah N = 241', 'standard deviation =',sigma) 

それはエラーを返します:

AttributeError: 'str' object has no attribute 'pop' 

または

AttributeError: 'int' object has no attribute 'pop' 

答えて

1

set_titleためdocumentationはそれがprintと同じように動作しないことを示しています。 3つの引数を指定し、2番目の引数はdictpop -ed)とします。あなたが文字列を渡したので、それは動作しません。

これを試してみてください:

sigma = float(some number) 
ax1.hist(population) 
title = 'blah N = 241, ' + 'standard deviation =' + str(sigma) 
ax1.set_title(title) 
1

ax.set_title()はタイトルが一つの文字列であることが必要です。あなたはset_title関数に渡す前に1つの文字列にすべての文字列の断片を収集する必要があります。

ax1.set_title('blah N = 241' + 'standard deviation =' + str(sigma)) 
関連する問題