stackplot overlapping objects on top of each other

Viewed 47

I was trying to plot overlapping clusters over the time, I used stackplot but when it moves to the next Y-axis (object) it hides the previous ones (it does not show all objects sorted based on the Y-values).

The original plot before using stackplot

The original plot before using stackplot

The output image using stackplot:

The output image using stackplot

This is the python script:

for r in rs:
rows = 3
columns = 4
fig = plt.figure(1, figsize=(columns * 11, rows * 8))

subplotNumber = 0
for a in range(4):
    subplotNumber += 1
    ax = fig.add_subplot(rows, columns, subplotNumber)
    toPlots = []
    for b in range(4):
        if a == b:
            toPlots.append((np.array(colorTypes[b]) / 255,
                            np.zeros(len(xticks)), keys[b]))
        elif a < b:
            toPlots.append((np.array(colorTypes[b]) / 255,
                            100 * np.array(X[keys[a]][keys[b]][r]),
                            keys[b]))
        else:
            toPlots.append((np.array(colorTypes[b]) / 255,
                            100 * np.array(X[keys[b]][keys[a]][r]),
                            keys[b]))
    for toPlot in toPlots:
        ax.stackplot(xticks, toPlot[1], color = toPlot[0])

    if a == 0:
        lgnd = ax.legend(toPlot[2],ncol=6, bbox_to_anchor=(3.5, 1.3),
                         prop={'size': 20})
        for handle in lgnd.legendHandles:
            handle.set_linewidth(20.0)
0 Answers
Related