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

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

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

问题

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

我的图表代码:

  1. xaxis={
  2. 'title':'',
  3. 'tick0':chartdata[chartdata.Date > date].index[0],
  4. 'dtick':'M1',
  5. 'tickformat':'%b\n%Y',
  6. 'tickangle':-45,
  7. },
  8. yaxis={
  9. 'title':'<b>Gross</b> Balances',
  10. 'tickprefix':'$',
  11. 'nticks':20,
  12. 'showgrid':True,
  13. },
  14. barmode='stack',

当前视图:
堆叠条形图

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

英文:

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

My code for the chart:

  1. xaxis={
  2. &#39;title&#39;:&quot;&quot;,
  3. &#39;tick0&#39;:chartdata[chartdata.Date &gt; date].index[0],
  4. &#39;dtick&#39;:&#39;M1&#39;,
  5. &#39;tickformat&#39;:&#39;%b\n%Y&#39;,
  6. &#39;tickangle&#39;:-45,
  7. },
  8. yaxis={
  9. &#39;title&#39;:&quot;&lt;b&gt;Gross&lt;/b&gt; Balances&quot;,
  10. &#39;tickprefix&#39;:&#39;$&#39;,
  11. &#39;nticks&#39;:20,
  12. &#39;showgrid&#39;:True,
  13. },
  14. 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

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

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

I believe the solution I was looking for was:

  1. fig.update_traces(
  2. xperiod=&quot;M1&quot;
  3. )

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:

确定