<legend id='iJYv8'><style id='iJYv8'><dir id='iJYv8'><q id='iJYv8'></q></dir></style></legend>
  • <small id='iJYv8'></small><noframes id='iJYv8'>

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

        人口金字塔,包括巨蟒和海上金字塔

        时间:2024-08-20

        <small id='6HWQs'></small><noframes id='6HWQs'>

          <bdo id='6HWQs'></bdo><ul id='6HWQs'></ul>

              <tbody id='6HWQs'></tbody>

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

              1. <legend id='6HWQs'><style id='6HWQs'><dir id='6HWQs'><q id='6HWQs'></q></dir></style></legend>
                • 本文介绍了人口金字塔,包括巨蟒和海上金字塔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试创建一个按性别分组的人口金字塔。不幸的是,我不能让它工作。情节只是一幅白色的图画,轴线似乎在某种程度上颠倒了过来。也许有人能帮我,谢谢。

                  import pandas as pd
                  import seaborn as sns
                  import matplotlib.pyplot as plt
                  
                  # I read this testdata from a csv file
                  testdata = pd.DataFrame({'age': [20, 20, 21, 21, 22, 22, 23, 23],
                                  'gender': ["male", "female", "male", "female", "male", "female", "male", "female"],
                                  'count': [10, -12, 13, -10, 16, -14, 17, -16]});
                  
                  
                  plt.figure(figsize=(13, 10), dpi=80)
                  group_col = 'gender'
                  order_of_bars = testdata['age'].unique()[::-1]
                  colors = [plt.cm.Spectral(i / float(len(testdata[group_col].unique()) - 1)) for i in range(len(testdata[group_col].unique()))]
                  
                  
                  for c, group in zip(colors, testdata[group_col].unique()):
                      barplot = sns.barplot(x='count', y='age', data=testdata.loc[testdata[group_col] == group, :], order=order_of_bars, color=c, label=group)
                  
                  plt.xlabel("Counts")
                  plt.ylabel("Age")
                  plt.yticks(fontsize=12)
                  plt.title("Pyramide", fontsize=22)
                  plt.legend()
                  plt.show()
                  

                  推荐答案

                  如果您要查找this population pyramid,我们试试:

                  sns.barplot(data=testdata, x='count',y='age',
                              hue='gender',orient='horizontal', 
                              dodge=False)
                  

                  输出:

                  这篇关于人口金字塔,包括巨蟒和海上金字塔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何使用海运dislot/histlot/dislot绘制百分比 下一篇:如何更改图例在海运中的位置?

                  相关文章

                • <tfoot id='in5HW'></tfoot>

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

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

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