2017-08-08 9 views
1

上の2つのプロットをしながら私は1つのボックスプロットで、プロットを作るためにseabornとmatplotlibのを使用しています:はAttributeError jupytherノートセル

ax = sns.boxplot(x=data["MEDV"]) 

もう一つは、私がのスケールを変更れるヒストグラムであります軸:私は別の細胞にそれらを作った場合

g = sns.distplot(data['MEDV']) 
plt.ticklabel_format(style='sci', axis='both', scilimits=(0,0)) 

両方のプロットはうまく動作しますが、私は同じセルを使用する場合:

ax = sns.boxplot(x=data["MEDV"]) 

g = sns.distplot(data['MEDV']) 
plt.ticklabel_format(style='sci', axis='both', scilimits=(0,0)) 

私は次のエラーを取得:あなたは2つのサブプロット、その中のプロットの一つとそれぞれたい場合

AttributeError: This method only works with the ScalarFormatter. 
+0

質問には完全な例がありませんが、boxplotはプロット上にテキストの目盛りのラベルを貼り付けています(数字ではないため、科学的表記法では表示できません)。 – mwaskom

答えて

1

を:

fig, (ax, ax2) = plt.subplots(ncols=2) 
sns.boxplot(x=data, ax=ax) 

sns.distplot(data, ax=ax2) 
plt.ticklabel_format(style='sci', axis='both', scilimits=(0,0)) 

enter image description here

を使用すると、2つの異なる図面、のための1つが必要な場合各プロット:

plt.figure() 
sns.boxplot(x=data) 

plt.figure() 
sns.distplot(data) 
plt.ticklabel_format(style='sci', axis='both', scilimits=(0,0)) 

enter image description here

関連する問題