我如何在Seaborn中并排绘制两个计数图? [英] How do I plot two countplot graphs side by side in seaborn?

查看:1234
本文介绍了我如何在Seaborn中并排绘制两个计数图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图绘制两个计数球,显示击球和保龄球的次数.我尝试了以下代码:

I am trying to plot two countplots showing the counts of batting and bowling. I tried the following code:

l=['batting_team','bowling_team']
for i in l:
    sns.countplot(high_scores[i])
    mlt.show()

但是通过使用它,我得到了两个地块,一个在另一个地块的下面.如何让他们并排订购?

But by using this , I am getting two plots one below the other. How can i make them order side by side?

推荐答案

类似以下内容:

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()

想法是在图中指定子图-有很多方法可以做到这一点,但是上面的方法可以很好地工作.

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

这篇关于我如何在Seaborn中并排绘制两个计数图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆