Plotly/Python: 如何填充/扩展月度时间序列以填充X轴?

huangapple go评论79阅读模式
英文:

Plotly/Python: How to fill/expand monthly time-series to fill the x-axis?

问题

在不扩展数据集的情况下,是否有方法来填补柱状图之间的空白?

我的图表代码:

xaxis={
    'title':'',
    'tick0':chartdata[chartdata.Date > date].index[0],
    'dtick':'M1',
    'tickformat':'%b\n%Y',
    'tickangle':-45,
},
yaxis={
    'title':'<b>Gross</b> Balances',
    'tickprefix':'$',
    'nticks':20,
    'showgrid':True,
},
barmode='stack',

当前视图:
堆叠条形图

目前它只显示数据集中月底的柱形图,并且柱形图之间有很多空白。

英文:

Is there a way without expanding the dataset to fill the gaps between bars?

My code for the chart:

    xaxis={
        &#39;title&#39;:&quot;&quot;,
        &#39;tick0&#39;:chartdata[chartdata.Date &gt; date].index[0],
        &#39;dtick&#39;:&#39;M1&#39;,
        &#39;tickformat&#39;:&#39;%b\n%Y&#39;,
        &#39;tickangle&#39;:-45,
    },
    yaxis={
        &#39;title&#39;:&quot;&lt;b&gt;Gross&lt;/b&gt; Balances&quot;,
        &#39;tickprefix&#39;:&#39;$&#39;,
        &#39;nticks&#39;:20,
        &#39;showgrid&#39;:True,
    },
    barmode=&#39;stack&#39;,

Current view:
stacked bar chart

Currently it is only displaying the bar @ month-end (according to the dataset) and there is a lot of white space between bars.

答案1

得分: 1

我相信我正在寻找的解决方案是:

fig.update_traces(
   xperiod="M1"
)
英文:

I believe the solution I was looking for was:

fig.update_traces(
   xperiod=&quot;M1&quot;
)

huangapple
  • 本文由 发表于 2023年3月4日 05:29:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75632032.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定