在Python中绘制多组值

在Python中绘制多组值,python,matplotlib,plot,seaborn,python-ggplot,Python,Matplotlib,Plot,Seaborn,Python Ggplot,我有一个像这样的数据框 country age new_user 298408 UK 32 1 193010 US 37 0 164494 UK 17 0 28149 US 34 0 297080 China 29 1 我想在Python的一个图表中绘制每个国家的新_用户数(20-30、30-40等年

我有一个像这样的数据框

        country  age  new_user  
298408      UK   32         1   
193010      US   37         0 
164494      UK   17         0   
28149       US   34         0  
297080   China   29         1    
我想在Python的一个图表中绘制每个国家的新_用户数(20-30、30-40等年龄组)

基本上,我需要为所有年龄组绘制新用户(值0),为所有国家的所有年龄组绘制新用户(值1)

我发现很难将年龄分为20-30岁、30-40岁等等。 有人能帮我用seaborn、ggplot或python中的matplotlib绘制这个图吗?这是最好的

多谢各位

import seaborn as sns
from pandas import DataFrame
from matplotlib.pyplot import show, legend
d = {"country": ['UK','US','US','UK','PRC'],
       "age": [32, 37, 17, 34, 29],
       "new_user": [1, 0, 0, 0,1]}

df = DataFrame(d)
bins = range(0, 100, 10)
ax = sns.distplot(df.age[df.new_user==1],
              color='red', kde=False, bins=bins, label='New')
sns.distplot(df.age[df.new_user==0],
         ax=ax,  # Overplots on first plot
         color='blue', kde=False, bins=bins, label='Existing')
legend()
show()


您必须
groupby
他们才能获得具有实际值的数据集。你知道了吗?直方图,带有明显的仓位大小你必须
groupby
它们才能得到具有实际值的数据集。你知道吗?直方图,有明显的箱子大小