I am implementing a seaborn (Version 0.11.1) catplot in Jupyter Notebook (Python 3.8).
The dataframe generated is generated by following code
city_lit_rate_long=city_lit_rate[{'Male Literacy','Female Literacy',
'National Average','City'}].melt(
['City'],var_name='Legend',value_name='Literacy Levels')
The sample output is
City,Legend,Literacy Levels
Ambala ,Male Literacy,91.58
Ambala ,National Average,85.13146044624753
Ambala ,Female Literacy,84.51
Ambikapur ,Female Literacy,83.29
Ambikapur ,Male Literacy,92.73
Ambikapur ,National Average,85.13146044624753
Basirhat ,Male Literacy,91.54
Basirhat ,Female Literacy,84.88
Basirhat ,National Average,85.13146044624753
Erode ,Male Literacy,93.18
Erode ,Female Literacy,83.65
Erode ,National Average,85.13146044624753
Hosur ,National Average,85.13146044624753
Hosur ,Male Literacy,91.57
Hosur ,Female Literacy,84.79
Kamarhati ,Female Literacy,85.43
Kamarhati ,Male Literacy,90.79
Kamarhati ,National Average,85.13146044624753
Kancheepuram ,Male Literacy,93.14
Kancheepuram ,National Average,85.13146044624753
Kancheepuram ,Female Literacy,83.59
Nadiad ,National Average,85.13146044624753
Nadiad ,Male Literacy,93.0
Nadiad ,Female Literacy,83.31
Osmanabad ,Female Literacy,82.52
Osmanabad ,Male Literacy,93.45
Osmanabad ,National Average,85.13146044624753
Ranchi ,Male Literacy,92.87
Ranchi ,Female Literacy,83.75
Ranchi ,National Average,85.13146044624753
Rewari ,Male Literacy,94.22
Rewari ,Female Literacy,81.61
Rewari ,National Average,85.13146044624753
Tiruvottiyur ,Male Literacy,91.59
Tiruvottiyur ,National Average,85.13146044624753
Tiruvottiyur ,Female Literacy,84.8
Thereafter I plot a Seaborn Catplot using the following code
plot=sns.catplot(data=city_lit_rate_long,y='City',
x='Literacy Levels', hue='Legend',
height=5,aspect=2,legend=True, legend_out=False)
which produces the
There are only 563 cities, and the first part of the code finished in approx 1.2 ms. But it takes 12 minutes for second part to plot the catplot!
I am using a AMD Ryzen 7 3750H laptop with 12 GB RAM. During execution of this code, CPU is loaded at about 21-23%.
Is there anyway to speed it up?