0

This is an example of my MatPlotLib 3D surface plot, which I generate with point data using this function:

def fill_between_3d(ax, x1, y1, z1, x2, y2, z2, mode=1, c='gray', alpha=1):
        for i in range(len(x1) - 1):
            verts = [(x1[i], y1[i], z1[i]), (x1[i + 1], y1[i + 1], z1[i + 1])] + \
                    [(x2[i + 1], y2[i + 1], z2[i + 1]), (x2[i], y2[i], z2[i])]

            collection = Poly3DCollection([verts], alpha=alpha, linewidths=1, color=c)
            #collection.monochrome = True
            collection.colorbar = matplotlib.cm.coolwarm
            #collection.set_verts(collection.verts, closed=True)
            #collection.edgecolor = 'orange'

            # Create random scalar field over the vertices
            scalar = np.random.rand(3, 4)
            # Modify scalar field such that values are consistent over coincident vertices
            scalar[1, 0:2] = scalar[0, 2:]
            scalar[2, 0:2] = scalar[1, 2:]
            averaged_scalar = np.mean(scalar, axis=1)
            m = mpl.cm.ScalarMappable(cmap=mpl.cm.cool)
            rgba_array = m.to_rgba(averaged_scalar)
            collection.set_facecolor([(i[0], i[1], i[2]) for i in rgba_array])

            collection.set_antialiased(True)

            ax.add_collection3d(collection)

For each face along this surface, how could I add a respective bar graph?

Please bear in mind, I have this 3D plot embedded in a QT widget, and I'd like to be able to switch between datasets and update all of the bar graphs as quickly as possible.

Thank you

I tried adding "3D Bar Charts", to no avail. I figured I would 'transform' each bar graph to the center coordinate of its respective face.

0 Answers0