I want to plot a stacked grouped bar char (as described here), to a Canvas in QT5. I managed to get it to work with a single axes, but in the below example ax=plt.subplot2grid
somehow creates multiple axes, and I'm not sure how this can be projected onto a QT figureCanvas. Currently there is no error message, but the plot is empty. Any suggestions are greatly apprecaited.
class BarPlotter2(FigureCanvas):
def __init__(self, ui_analyser, lst):
self.fig = Figure(dpi=70)
self.axes = self.fig.add_subplot(111) # This is most probably wrong?
super(BarPlotter2, self).__init__(self.fig)
self.drawfigure()
def drawfigure(self):
self.fig.clf()
df = get_data()
clusters = df.index.levels[0]
gridspec.GridSpec(1, total_width)
axes = []
ax_position = 0
for cluster in clusters:
subset = df.loc[cluster]
self.axes = subset.plot(kind="bar", stacked=True, width=0.8,
ax=plt.subplot2grid((1, total_width), (0, ax_position), colspan=len(subset.index)))
axes.append(self.axes)
self.axes.set_title(cluster)
ax_position += len(subset.index) + inter_graph
for i in range(1, len(clusters)):
axes[i].set_yticklabels("")
axes[i - 1].legend().set_visible(False)
axes[0].set_ylabel("y_label")
self.draw()