How can I plot a stacked bar graph for an unequal data set?
I tried, and it is plotting only an equal number (minimum) of values on y.
My data looks like this -
import plotly.graph_objects as go
forx = [1,2,3,4,5]
fory = [[4,6,8], [2,9], [5], [3,1,5,2], [6,8]]
data = []
for idx, i in enumerate(forx):
data.append(go.Bar(name=str(i), x=forx, y=fory[idx]))
fig.update_layout(barmode='stack')
fig.show()
I had tried filling/padding 0s, It didnβt solve my problem.
The issues seem to be because of x axis position is selecting respecting index on y axis arrays and stacking them up.
x axis 0 picks all elements of 0 from all y axis arrays. i.e 1 on x axis will pick 4,2,5,3,6 from y axis arrays.
How do I make it stack all elements of a whole array, instead of individual elements of position from different arrays?
i.e x axis 1 to stacks y axis array [4,6,8]