0

I have a iris dataset and I'm trying to plot a distribution plot for all 4 columns of iris dataset :

df.columns    
['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)',
           'petal width (cm)']

I want to plot distribution of values I tried.

fig, (ax1,ax2,ax3,ax4)= plt.subplots(2,2)
sns.distplot(a = df.iloc[:,0])

I get a ValueError:

ValueError                                Traceback (most recent call last)
<ipython-input-265-58940645d27a> in <module>()
----> 1 fig, (ax1,ax2,ax3,ax4)= plt.subplots(2,2)
      2 sns.distplot(a = df.iloc[:,0])

ValueError: not enough values to unpack (expected 4, got 2)
Diziet Asahi
  • 38,379
  • 7
  • 60
  • 75
Jeeth
  • 2,226
  • 5
  • 24
  • 60

1 Answers1

4

plt.subplots(2,2) returns a 2x2 array. If you want to unpack it, you need to provide the correct shape:

fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2,2)
Diziet Asahi
  • 38,379
  • 7
  • 60
  • 75