1

I'm working, in a Jupyter Notebook, with a dataframe that's pretty large. Here is a tiny sample of what I'm dealing with.

import pandas as pd
import seaborn as sns

# Intitialise data of lists
data = [{'Month': '2020-01-01', 'Expense':1000, 'Revenue':5000, 'Building':'Stadium'}, 
       {'Month': '2020-02-01', 'Expense':3000, 'Revenue':4000, 'Building':'Stadium'},
       {'Month': '2020-03-01', 'Expense':7000, 'Revenue':5000, 'Building':'Stadium'}, 
       {'Month': '2020-04-01', 'Expense':3000, 'Revenue':4000, 'Building':'Stadium'},
       {'Month': '2020-01-01', 'Expense':5000, 'Revenue':6000, 'Building':'Casino'}, 
       {'Month': '2020-02-01', 'Expense':5000, 'Revenue':4000, 'Building':'Casino'},
       {'Month': '2020-03-01', 'Expense':5000, 'Revenue':9000, 'Building':'Casino'},
       {'Month': '2020-04-01', 'Expense':6000, 'Revenue':10000, 'Building':'Casino'},
       {'Month': '2020-01-01', 'Expense':5000, 'Revenue':6000, 'Building':'School'}, 
       {'Month': '2020-02-01', 'Expense':5000, 'Revenue':4000, 'Building':'School'},
       {'Month': '2020-03-01', 'Expense':5000, 'Revenue':9000, 'Building':'School'},
       {'Month': '2020-04-01', 'Expense':6000, 'Revenue':10000, 'Building':'School'},
       {'Month': '2020-01-01', 'Expense':5000, 'Revenue':6000, 'Building':'Hospital'}, 
       {'Month': '2020-02-01', 'Expense':5000, 'Revenue':4000, 'Building':'Hospital'},
       {'Month': '2020-03-01', 'Expense':5000, 'Revenue':9000, 'Building':'Hospital'},
       {'Month': '2020-04-01', 'Expense':6000, 'Revenue':10000, 'Building':'Hospital'},
       {'Month': '2020-01-01', 'Expense':5000, 'Revenue':6000, 'Building':'Arena'}, 
       {'Month': '2020-02-01', 'Expense':5000, 'Revenue':4000, 'Building':'Arena'},
       {'Month': '2020-03-01', 'Expense':5000, 'Revenue':9000, 'Building':'Arena'},
       {'Month': '2020-04-01', 'Expense':6000, 'Revenue':10000, 'Building':'Arena'}]
df = pd.DataFrame(data)
df

enter image description here

I received some great advice from people yesterday, on how to plot this.

dfm = df.melt(id_vars=['Month', 'Building'], value_vars=['Expense', 'Revenue'])
sns.catplot(kind='bar', data=dfm, x='Month', y='value', hue='variable', col='Building')
plt.show()

Now, this works, but everything is so tiny, I can't even tell what's what.

enter image description here

I tried three ways to try to increase the size of each graph.

1)

sns.set(rc = {'figure.figsize':(15,8)})
p = sns.lineplot(data = df)
plt.gcf().set_size_inches(15, 8)
from matplotlib import rcParams
rcParams['figure.figsize'] = 15,8
p = sns.lineplot(data = df)

None of these code samples did anything to change the size of any plot. Has anyone here encountered this before? Any thoughts on how to increase the size of each of these plots?

ASH
  • 20,759
  • 19
  • 87
  • 200

2 Answers2

0

You can try to use the size and aspect parameters of the seaborn plot.

Size changes the height, while maintaining the aspect ratio. Aspect changes the width while keeping the height constant.

Cristian M
  • 195
  • 1
  • 1
  • 15
-1

you have give the values to height and aspect parameters inside the sns.catplot() call.

sns.set(rc={'figure.figsize':(10, 15)})

dfm = df.melt(id_vars=['Month', 'Building'], value_vars=['Expense', 'Revenue'])
sns.catplot(kind='bar', data=dfm, x='Month', y='value', hue='variable', col='Building', height=15, aspect=10/15)
plt.show()
Priya
  • 723
  • 1
  • 5
  • 7