close

How do I plot two countplot graphs side by side in seaborn?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How do I plot two countplot graphs side by side in seaborn in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How do I plot two countplot graphs side by side in seaborn?

  1. How do I plot two countplot graphs side by side in seaborn?

    The idea is to specify the subplots in the figure – there are numerous ways to do this but the above will work fine.

  2. plot two countplot graphs side by side in seaborn

    The idea is to specify the subplots in the figure – there are numerous ways to do this but the above will work fine.

Method 1

Something like this:

import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt

batData = ['a','b','c','a','c']
bowlData = ['b','a','d','d','a']

df=pd.DataFrame()
df['batting']=batData
df['bowling']=bowlData


fig, ax =plt.subplots(1,2)
sns.countplot(df['batting'], ax=ax[0])
sns.countplot(df['bowling'], ax=ax[1])
fig.show()
enter image description here

The idea is to specify the subplots in the figure – there are numerous ways to do this but the above will work fine.

Method 2

import matplotlib.pyplot as plt
l=['batting_team', 'bowling_team']
figure, axes = plt.subplots(1, 2)
index = 0
for axis in axes:
  sns.countplot(high_scores[index])
  index = index+1
plt.show()

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read