<tfoot id='tSQ8Q'></tfoot>
        • <bdo id='tSQ8Q'></bdo><ul id='tSQ8Q'></ul>

        <i id='tSQ8Q'><tr id='tSQ8Q'><dt id='tSQ8Q'><q id='tSQ8Q'><span id='tSQ8Q'><b id='tSQ8Q'><form id='tSQ8Q'><ins id='tSQ8Q'></ins><ul id='tSQ8Q'></ul><sub id='tSQ8Q'></sub></form><legend id='tSQ8Q'></legend><bdo id='tSQ8Q'><pre id='tSQ8Q'><center id='tSQ8Q'></center></pre></bdo></b><th id='tSQ8Q'></th></span></q></dt></tr></i><div id='tSQ8Q'><tfoot id='tSQ8Q'></tfoot><dl id='tSQ8Q'><fieldset id='tSQ8Q'></fieldset></dl></div>

      1. <small id='tSQ8Q'></small><noframes id='tSQ8Q'>

        <legend id='tSQ8Q'><style id='tSQ8Q'><dir id='tSQ8Q'><q id='tSQ8Q'></q></dir></style></legend>

        Seborn:如何在计数图中显示数值?

        Seaborn: How to show values in a countplot?(Seborn:如何在计数图中显示数值?)

        <small id='YrMPj'></small><noframes id='YrMPj'>

          1. <legend id='YrMPj'><style id='YrMPj'><dir id='YrMPj'><q id='YrMPj'></q></dir></style></legend>
            • <i id='YrMPj'><tr id='YrMPj'><dt id='YrMPj'><q id='YrMPj'><span id='YrMPj'><b id='YrMPj'><form id='YrMPj'><ins id='YrMPj'></ins><ul id='YrMPj'></ul><sub id='YrMPj'></sub></form><legend id='YrMPj'></legend><bdo id='YrMPj'><pre id='YrMPj'><center id='YrMPj'></center></pre></bdo></b><th id='YrMPj'></th></span></q></dt></tr></i><div id='YrMPj'><tfoot id='YrMPj'></tfoot><dl id='YrMPj'><fieldset id='YrMPj'></fieldset></dl></div>
                <tbody id='YrMPj'></tbody>
            • <tfoot id='YrMPj'></tfoot>
                <bdo id='YrMPj'></bdo><ul id='YrMPj'></ul>
                1. 本文介绍了Seborn:如何在计数图中显示数值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有数据显示某个性别的人是否有孩子(1)或没有(0)。这在countplot中显示。但是,我希望将值放在列中,或者放在列的顶部。我如何才能做到这一点?

                  请不要发送指向其他答案的链接,因为我已经检查过,但我不理解。 请简单地修改我的代码,我将能够在我的情况下使用。

                  df = pd.DataFrame({"Gender":["Male", "Male", "Female", "Male", "Female", "Female"],
                                     "children":["0", "1", "0", "0", "1", "1"]})
                  
                  sns.countplot(x="Gender", hue="children", data=df, palette="binary")
                  

                  推荐答案

                  只需循环访问countplot返回的所有补丁。然后,在给定每个面片的x位置和高度的情况下创建文本。我选择了白色并添加了换行符,以在栏顶部正下方显示数字。

                  部分代码:

                  import pandas as pd
                  import seaborn as sns
                  from matplotlib import pyplot as plt
                  
                  df = pd.DataFrame({"Gender":["Male", "Male", "Female", "Male", "Female", "Female", "Male", "Male", "Female", "Male", "Female", "Female"],
                                     "Children":["0", "1", "0", "0", "1", "1", "0", "1", "0", "0", "1", "1"]})
                  ax = sns.countplot(x="Gender", hue="Children", data=df, palette="plasma")
                  ax.set_title('Survival in terms of gender', fontsize=20)
                  for p in ax.patches:
                      ax.annotate(f'
                  {p.get_height()}', (p.get_x()+0.2, p.get_height()), ha='center', va='top', color='white', size=18)
                  plt.show()
                  

                  这篇关于Seborn:如何在计数图中显示数值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Is there a way of group by month in Pandas starting at specific day number?( pandas 有从特定日期开始的按月分组的方式吗?)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)

                      <tbody id='FQASx'></tbody>

                        <bdo id='FQASx'></bdo><ul id='FQASx'></ul>
                      • <legend id='FQASx'><style id='FQASx'><dir id='FQASx'><q id='FQASx'></q></dir></style></legend>
                        <i id='FQASx'><tr id='FQASx'><dt id='FQASx'><q id='FQASx'><span id='FQASx'><b id='FQASx'><form id='FQASx'><ins id='FQASx'></ins><ul id='FQASx'></ul><sub id='FQASx'></sub></form><legend id='FQASx'></legend><bdo id='FQASx'><pre id='FQASx'><center id='FQASx'></center></pre></bdo></b><th id='FQASx'></th></span></q></dt></tr></i><div id='FQASx'><tfoot id='FQASx'></tfoot><dl id='FQASx'><fieldset id='FQASx'></fieldset></dl></div>
                          • <small id='FQASx'></small><noframes id='FQASx'>

                            <tfoot id='FQASx'></tfoot>