I am trying to plot either 4 graphs (subplots) of KDE or 1 with 4 lines. I have two columns:
Region: Charges:
southeast 6000
southeast 5422
southwest 3222
northwest 4222
northwest 5555
northeast 6729
etc 1000s of rows..4 regions
I'd like to visualize the distribution of these 4 areas.
Playing around with this and error messages (and I know it's not correct) 'Data must be 1-dimensional'
.
fig, axes = plt.subplots(2, 2, sharex=True, figsize=(10,5))
fig.suptitle('Bigger 1 row x 2 columns axes with no data')
#axes[0].set_title('Title of the first chart')
reg_name = df2[['region','charges']].set_index('region')
southeast = reg_name.loc['southeast']
southwest = reg_name.loc['southwest']
northwest = reg_name.loc['northwest']
#c = df2.charges.values
#d = df2.region
# Set the dimensions of the plot
#widthInInches = 10
#heightInInches = 4
#plt.figure( figsize=(widthInInches, heightInInches) )
# Draw histograms and KDEs on the diagonal usin
#if( int(versionStrParts[1]) < 11 ):
# Use the older, now-deprectaed form
# ax = sns.distplot(c,
# kde_kws={"label": "Kernel Density", "color" : "black"},
# hist_kws={"label": "Histogram", "color" : 'lightsteelblue'})
#else:
# Use the more recent for
sns.kdeplot(ax=axes[0], x=southeast.index, y=southeast.values, color="black", label="Kernel Density")
axes[0].set_title(southeast.name)
sns.kdeplot(ax=axes[1], x=southwest.index, y=southwest.values, color="black", label="Kernel Density")
axes[1].set_title(southwest.name)