<tfoot id='4vvC4'></tfoot>
  • <legend id='4vvC4'><style id='4vvC4'><dir id='4vvC4'><q id='4vvC4'></q></dir></style></legend>

      <small id='4vvC4'></small><noframes id='4vvC4'>

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

        利用matplotlib和 pandas 制作分组图

        making groupby plot using matplotlib and pandas(利用matplotlib和 pandas 制作分组图)

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

                <tbody id='oo7Y4'></tbody>

              1. <legend id='oo7Y4'><style id='oo7Y4'><dir id='oo7Y4'><q id='oo7Y4'></q></dir></style></legend>

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

                1. 本文介绍了利用matplotlib和 pandas 制作分组图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个将图形绘制为花朵的代码

                  代码为

                  import matplotlib.pyplot as plt
                  import pandas as pd
                  
                  years=["ASD","MNG","KQR","MND","QST", "MNR"]
                  dataavail={
                      "Jan":[20,20,30,19,10,21],
                      "Feb":[20,13,10,18,15,30],
                      "Mar":[20,20,10,15,18,30],
                      "Apr":[20,20,10,15,18,0],
                      "May":[20,20,10,15,18,0],
                      "Jun":[20,20,10,15,18,0],
                      "Jul":[20,20,10,15,18,0],
                      "Aug":[20,20,10,15,18,45],
                      "Sep":[20,20,10,15,18,0],
                      "Oct":[20,20,10,15,18,0],
                      "Nov":[20,20,10,15,18,0],
                      "Dec":[20,20,0,0,0,0],
                  }
                  
                  
                  df_month = pd.DataFrame(dataavail, index=years)
                  fig, ax1 = plt.subplots(1, figsize=(8, 5))
                  df_month.plot(kind='bar', stacked=True, colormap=plt.cm.tab20, ax=ax1)
                  plt.legend(loc="upper right", ncol = 3,handlelength=1.5, borderpad=0.2, labelspacing=0.2) 
                  plt.xticks(rotation=0)
                  plt.show()
                  
                  但是,我需要的不是堆叠图,而是GROUPBY图,如附图,其中x轴应该与第一个图相同。有人能在这方面帮我吗?

                  推荐答案

                  iUC是否需要非堆叠条形图?

                  df_month.plot.bar()
                  

                  输出:

                  使用您的代码:

                  您应该删除stacked=True(或使用stacked=False):

                  df_month = pd.DataFrame(dataavail, index=years)
                  fig, ax1 = plt.subplots(1, figsize=(8, 5))
                  df_month.plot(kind='bar', stacked=False, colormap=plt.cm.tab20, ax=ax1)
                  plt.legend(loc="upper right", ncol = 3,handlelength=1.5, borderpad=0.2, labelspacing=0.2) 
                  plt.xticks(rotation=0)
                  plt.show()
                  

                  这篇关于利用matplotlib和 pandas 制作分组图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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替换为非空值)

                  1. <legend id='N7PH3'><style id='N7PH3'><dir id='N7PH3'><q id='N7PH3'></q></dir></style></legend>

                          <tbody id='N7PH3'></tbody>
                          <bdo id='N7PH3'></bdo><ul id='N7PH3'></ul>
                          <tfoot id='N7PH3'></tfoot>

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

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