def rysuj_wykres(self, tablica_cash_flow, tablica_wolumenow, cf_laczone): try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: _fromUtf8 = lambda s: s self.qwtPlot.hide() self.qwtPlot.destroy() self.qwtPlot = Qwt.QwtPlot(self.tab_3) self.qwtPlot.setGeometry(QtCore.QRect(0, 0, 891, 256)) self.qwtPlot.setObjectName(_fromUtf8("qwtPlot")) self.qwtPlot.setAxisScale(Qwt.QwtPlot.xBottom, 0.0, len(tablica_cash_flow)) self.qwtPlot.setAxisScale( Qwt.QwtPlot.yLeft, min(cf_laczone), max(max(tablica_cash_flow), max(tablica_wolumenow))) grid = Qwt.QwtPlotGrid() grid.enableXMin(True) grid.enableYMin(True) grid.setMajPen(QtGui.QPen(QtGui.QColor(0, 0, 0), 1)) grid.setMinPen(QtGui.QPen(QtGui.QColor(100, 100, 100), 1)) grid.attach(self.qwtPlot) #histogram = HistogramItem() #histogram.setColor(QtGui.QColor(170,170,100)) numValues = len(tablica_cash_flow) intervals = [] values = Qwt.QwtArrayDouble(numValues) argumenty = range(len(values)) argumenty2 = [] for arg in argumenty: argumenty2.append(float(arg)) #argumenty2 = Qwt.QwtArrayDouble() i = 0 #for args in argumenty: curve = Qwt.QwtPlotCurve("Curve " + str(i)) curve.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 255, 0)), 2)) # cash flow zielone curve.setData(argumenty2, tablica_cash_flow) curve.attach(self.qwtPlot) i = 1 curve2 = Qwt.QwtPlotCurve("Curve " + str(i)) curve2.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(255, 0, 0)), 2)) # wolumen czerwony curve2.setData(argumenty2, tablica_wolumenow) curve2.attach(self.qwtPlot) i = 3 curve3 = Qwt.QwtPlotCurve("Curve " + str(i)) curve3.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 255)), 2)) # suma niebieska curve3.setData(argumenty2, cf_laczone) curve3.attach(self.qwtPlot) self.qwtPlot.replot() self.qwtPlot.show()
def __init__(self, parent=None, name=''): Qwt.QwtPlot.__init__(self, parent) self._log = logging.getLogger(ConfigStatic.logger_name) self._log.info('passed') self.__name = name self._font_app = QtGui.QFont() dpi = 96 # TODO test physicalDpi (funguje v MainWindow.py) self._dpi2px = dpi*(1/2.54) self._plotSpeed = EnumPlotSpeed.oneCmMin self._plotBpm = EnumPlotBpm.twentyBpmCm self._plotBpmMajorTick = self._plotBpm #: Doc comment for instance attribute qux. self._minView = 0 self._maxView = 240 self._min_view_paper_lim = 0 self._max_view_paper_lim = 240 self._paper_format = EnumPaperFormat.EU self._minTime = 0 self._maxTime = 0 self._centerPoint = 0 self.__sampling_freq = 4 self._x = np.zeros(1) self._y = np.zeros(1) self._timeString = list() self._define_paper() # self.__canvasXMap = self.canvasMap(Qwt.QwtPlot.xBottom) # self.__canvasYMap = self.canvasMap(Qwt.QwtPlot.yLeft) self.setCanvasBackground(Qt.Qt.white) self.setAxisTitle(Qwt.QwtPlot.xBottom, "Time [min]") self.setAxisTitle(Qwt.QwtPlot.yLeft, "") # curves self.curve1 = Qwt.QwtPlotCurve('signal') # #self.curve1.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased) # self.curve1.setPen(QPen(Qt.Qt.black,0, Qt.Qt.SolidLine)) # self.curve1.setYAxis(Qwt.QwtPlot.yLeft) # self.curve1.attach(self) self._baseline = Qwt.QwtPlotMarker() ''' annotations ''' self.__d_ann_all_curves = dict() self.d_ann_all_curves_navplot = dict() self.__ann_action = 0 self.caliper = Caliper(self, EnumAnnType.plot_fhr, EnumAnnType.caliper) # self.caliper.plot() # time scale - for string time scale self.timeScale = TimeScaleDraw(self) self.setAxisScaleDraw(Qwt.QwtPlot.xBottom, self.timeScale) # time scale - for Y axis self.yAxisScale = AxisYScaleDraw(self) self.setAxisScaleDraw(Qwt.QwtPlot.yLeft, self.yAxisScale) self._bPlotDatesXAxis = False self._time_tics_located = list() self._locator_min = 5 self._locator_hour = 0 # grid self.grid = Qwt.QwtPlotGrid() self.grid.enableYMin(True) self.grid.enableXMin(True) self.grid.setMajPen(QtGui.QPen(Qt.Qt.lightGray, 0, Qt.Qt.SolidLine)) self.grid.setMinPen(QtGui.QPen(Qt.Qt.lightGray, 0, Qt.Qt.DotLine)) self.grid.attach(self) self.__set_axis_app_font()