def populate(self): colors = [colours["DarkOrchid"], colours["SteelBlue"], colours["Gold"]] numSamples = 5 numBars = len(colors) titles = [] for i in range(numBars): titles.append(Qwt.QwtText("Bar %d" % i)) self.d_barChartItem.setBarTitles(titles) self.d_barChartItem.setLegendIconSize(QSize(10, 14)) for i in range(numBars): symbol = Qwt.QwtColumnSymbol(Qwt.QwtColumnSymbol.Box) symbol.setLineWidth(2) symbol.setFrameStyle(Qwt.QwtColumnSymbol.Raised) symbol.setPalette(QPalette(colors[i])) self.d_barChartItem.setSymbol(i, symbol) self.series = [] for i in range(numSamples): values = [] for j in range(numBars): values.append(2.0 + random.randint(0, 8) % 8) self.series.append(values) print(self.series) self.d_barChartItem.setSamples(self.series)
def setMode(self, mode): #QwtPlotItemList #print("Set mode %d"%mode) items = self.itemList(Qwt.QwtPlotItem.Rtti_PlotHistogram) for i in range(len(items)): histogram = items[i] if (mode < 3): histogram.setStyle(mode) histogram.setSymbol(None) pen = QPen(Qt.black, 0) if (mode == Qwt.QwtPlotHistogram.Lines): pen.setBrush(histogram.brush()) histogram.setPen(pen) else: histogram.setStyle(Qwt.QwtPlotHistogram.Columns) symbol = Qwt.QwtColumnSymbol(Qwt.QwtColumnSymbol.Box) symbol.setFrameStyle(Qwt.QwtColumnSymbol.Raised) symbol.setLineWidth(2) symbol.setPalette(QPalette(histogram.brush().color())) histogram.setSymbol(symbol)