I'm using plotly to display a stacked bar chart with cummulative counts of objects. For context, the x-axis is dates and y-axis is the count of some names. There are 5 people who do these counts on different days and I want to display the count each of them does on each day so the stacked bar chart comes into play. Now there are some days where no one has counted names so there is no data and there is a gap in the bar chart. Ideally, since this is a cummulative count, I'd like the count for these 'empty' days to be the same bar chart as the previous day so that the graph is continuous. How do I achieve this? Here is python code below :
traces = []
for r in pivot_data.index.tolist():
trace = go.Bar(
name = r,
x=pivot_data.columns.tolist(), # these are all the dates in the dataset
y=pivot_data.loc[r].fillna(0).values.cumsum().tolist(), # get values for each date
)
traces.append(trace)
data = traces
layout = go.Layout(title="Cummulative Name count per volunteer for each weekday", xaxis=
{'title':'Date'}, yaxis={'title':'Name count'}, xaxis_tickangle=-45,
barmode='stack'
)
fig = go.Figure(data=data, layout=layout)
iplot(fig)
The data frame is pivoted and here is how it looks with recipients being the index:
pivot_data
Date 2019-06-01 00:00:00 2019-06-02 00:00:00
names
Mark Jones 3.0 NaN
Dennis Smith NaN 1.0
Let me know if any other information is required.