• <legend id='KH0WK'><style id='KH0WK'><dir id='KH0WK'><q id='KH0WK'></q></dir></style></legend>

  • <small id='KH0WK'></small><noframes id='KH0WK'>

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

        Plotly:如何从 x 轴删除空日期?

        Plotly: How to remove empty dates from x axis?(Plotly:如何从 x 轴删除空日期?)

          • <small id='XXmOb'></small><noframes id='XXmOb'>

              <tbody id='XXmOb'></tbody>
              <legend id='XXmOb'><style id='XXmOb'><dir id='XXmOb'><q id='XXmOb'></q></dir></style></legend>
              <i id='XXmOb'><tr id='XXmOb'><dt id='XXmOb'><q id='XXmOb'><span id='XXmOb'><b id='XXmOb'><form id='XXmOb'><ins id='XXmOb'></ins><ul id='XXmOb'></ul><sub id='XXmOb'></sub></form><legend id='XXmOb'></legend><bdo id='XXmOb'><pre id='XXmOb'><center id='XXmOb'></center></pre></bdo></b><th id='XXmOb'></th></span></q></dt></tr></i><div id='XXmOb'><tfoot id='XXmOb'></tfoot><dl id='XXmOb'><fieldset id='XXmOb'></fieldset></dl></div>
                <bdo id='XXmOb'></bdo><ul id='XXmOb'></ul>
                <tfoot id='XXmOb'></tfoot>
                • 本文介绍了Plotly:如何从 x 轴删除空日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个数据框

                     Date        Category    Sum
                  0  2019-06-03    "25M"      34
                  1  2019-06-03    "25M"      60
                  2  2019-06-03    "50M"      23
                  3  2019-06-04    "25M"      67
                  4  2019-06-05    "50M"     -90
                  5  2019-06-05    "50M"     100
                  6  2019-06-06    "100M"     6
                  7  2019-06-07    "25M"     -100
                  8  2019-06-08    "100M"     67
                  9  2019-06-09    "25M"      450
                  10 2019-06-10    "50M"      600
                  11 2019-06-11    "25M"      -9
                  12 2019-07-12    "50M"      45
                  13 2019-07-13    "50M"      67
                  14 2019-07-14    "100M"    130
                  15 2019-07-14    "50M"      45
                  16 2019-07-15    "100M"    100
                  17 2019-07-16    "25M"     -90
                  18 2019-07-17    "25M"     700
                  19 2019-07-18    "25M"     -9
                  

                  我想创建一个绘图图,显示在每个描述的日期为不同的类别"添加了总和",但如果日期没有任何数据,我想删除它们.

                  I want to create a plotly graph showing the addition of "Sum" for different "Category" on Every described date, but want to remove dates, if they don't have any data.

                  代码

                  df["Date"]=pd.to_datetime(df["Date"], format=("%Y%m%d"))
                  df=df.sort_values(["Date","Category","Sum"],ascending=False)
                  df=round(df.groupby(["Date","Category"]).agg({"Sum":"sum"}).reset_index(),1)
                  
                  
                  fig = px.bar(df, x=df["Date"] , y='Sum',barmode="group",color="Category") 
                  fig.update_xaxes(
                  rangeslider_visible=True,
                  rangeselector=dict(
                      buttons=list([
                          dict(count=1, label="day", step="day", stepmode="todate"),
                          dict(count=24, label="montly", step="month", stepmode="todate"),
                          dict(count=1, label="year", step="year", stepmode="todate"),
                          dict(step="all")
                      ])
                     ))
                  
                  
                  fig.show()
                  

                  我得到这样的图表,但我想从绘图图中删除空日期

                  推荐答案

                  我的图表也有同样的问题.只需在布局代码中添加以下内容:

                  I had the same problem with my graph. Just add the following to layout code:

                  xaxis=dict(type = "category")
                  

                  注意:我使用 import plotly.graph_objs as goNOT import plotly.express as px

                  这对我有用.希望对你也有帮助.

                  This worked for me. Hope it helps you too.

                  这篇关于Plotly:如何从 x 轴删除空日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)

                    <bdo id='s5WmR'></bdo><ul id='s5WmR'></ul>

                        <tfoot id='s5WmR'></tfoot>
                        <legend id='s5WmR'><style id='s5WmR'><dir id='s5WmR'><q id='s5WmR'></q></dir></style></legend>
                          <tbody id='s5WmR'></tbody>
                        • <small id='s5WmR'></small><noframes id='s5WmR'>

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