0

When I plot on a single chart with this code get a normal-looking chart.

df_bga= df.loc[(df['Dispensary'] == 'Lazy River Products')]
bga1= sns.countplot(y="Brand Name",data=df_bga)
bga1.set( title= " Flower Sku Count")
bga1.tick_params(axis='x', rotation=0) 

Normal chart

Loop chart code:

dispo = df_8th['Dispensary'].unique()
for i in dispo:
    df_loop= df.loc[(df['Dispensary'] == i)]
    c1= sns.countplot(y="Brand Name", data=df_loop)
    c1.set( title= i+" Flower Sku Count")
    c1.figure.savefig("count_charts/"+str(i) +" Brand Skus.png", format="PNG")

But when I try to loop through a bunch of data I get charts like this: Looped chart

How do I loop through data and create multiple charts?

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Dookie9636
  • 25
  • 5
  • Does this answer your question? [How to plot in multiple subplots](https://stackoverflow.com/questions/31726643/how-to-plot-in-multiple-subplots) – Trenton McKinney Sep 10 '21 at 01:31
  • 1
    Section 2 of this [answer](https://stackoverflow.com/a/68793513/7758804), just use `sns.countplot` for `df[col].plot`. You can also just do a `df.loc[df['Dispensary'].eq( i), "Brand Name"].value_counts().plot.bar()`, then there's no need for seaborn. – Trenton McKinney Sep 10 '21 at 01:35
  • Otherwise, use `p = sns.catplot(kind='count', data=df_8th, col='Dispensary', col_wrap=3, y='Brand Name')`. – Trenton McKinney Sep 10 '21 at 01:38
  • `sns.countplot(data=df_8th, y='Brand Name', hue='Dispensary')` – Trenton McKinney Sep 10 '21 at 01:41
  • This question is not reproducible without **data**. Please see [How to provide a reproducible copy of your DataFrame using `df.head(30).to_clipboard(sep=',')`](https://stackoverflow.com/q/52413246/7758804), then **[edit] your question**, and paste the clipboard into a code block. Always provide a [mre] **with code, data, errors, current output, and expected output, as [formatted text](https://stackoverflow.com/help/formatting)**. If relevant, plot images are okay. – Trenton McKinney Sep 10 '21 at 02:09

0 Answers0