Exemplo n.º 1
0
 def draw_y_axis(self):
     lineItem = QGraphicsLineItem(0, self.coordY(self.ylim[0]),
                                  0, self.coordY(self.ylim[1]),
                                  parent=self.item)
     lineItem.setPen(QPen(QColor('black')))
     lineItem.setZValue(10)
     max_w = 0
     for y in set(self.hlines + list(self.ylim)):
         lineItem = QGraphicsLineItem(0, self.coordY(y),
                                            -5, self.coordY(y),
                                            parent=self.item)
         lineItem.setPen(QPen(QColor('black')))
         lineItem.setZValue(10)
         text = QGraphicsSimpleTextItem(str(y))
         text.setFont(QFont("Arial", self.fsize-2))
         text.setParentItem(self.item)
         tw = text.boundingRect().width()
         max_w = tw if tw > max_w else max_w
         th = text.boundingRect().height()
         # Center text according to masterItem size
         text.setPos(-tw - 5, self.coordY(y)-th/2)
     if self.ylabel:
         text = QGraphicsSimpleTextItem(self.ylabel)
         text.setFont(QFont("Arial", self.fsize-1))
         text.setParentItem(self.item)
         text.rotate(-90)
         tw = text.boundingRect().width()
         th = text.boundingRect().height()
         # Center text according to masterItem size
         text.setPos(-th -5-max_w, tw/2+self.coordY(sum(self.ylim)/2))
Exemplo n.º 2
0
    def draw_x_axis(self):
        #lineItem = QGraphicsLineItem(self.col_w/2,
        #                                   self.coordY(self.ylim[0])+2,
        #                                   self.width-self.col_w/2,
        #                                   self.coordY(self.ylim[0])+2,
        #                                   parent=self.item)
        #lineItem.setPen(QPen(QColor('black')))
        #lineItem.setZValue(10)
        #all_vals = list(range(0, len(self.values), 5))
        #if (len(self.values)-1)%5:
        #    all_vals += [len(self.values)-1]
        for x, lab in enumerate(self.values):
#            lineItem = QGraphicsLineItem(0, self.coordY(self.ylim[0])+2,
#                                               0, self.coordY(self.ylim[0])+6,
#                                               parent=self.item)
#            lineItem.setX(x*self.col_w + self.col_w/2)
#            lineItem.setPen(QPen(QColor('black')))
#            lineItem.setZValue(10)
            text = QGraphicsSimpleTextItem(str(lab))
            text.rotate(-90)
            text.setFont(QFont("Arial", self.fsize-2))
            text.setParentItem(self.item)
            tw = text.boundingRect().height()
            # Center text according to masterItem size
            text.setPos(x*self.col_w-tw/2 + self.col_w/2,
                        self.coordY(self.ylim[0]))
Exemplo n.º 3
0
 def draw_y_axis(self):
     lineItem = QGraphicsLineItem(0,
                                  self.coordY(self.ylim[0]),
                                  0,
                                  self.coordY(self.ylim[1]),
                                  parent=self.item)
     lineItem.setPen(QPen(QColor('black')))
     lineItem.setZValue(10)
     max_w = 0
     for y in set(self.hlines + list(self.ylim)):
         lineItem = QGraphicsLineItem(0,
                                      self.coordY(y),
                                      -5,
                                      self.coordY(y),
                                      parent=self.item)
         lineItem.setPen(QPen(QColor('black')))
         lineItem.setZValue(10)
         text = QGraphicsSimpleTextItem(str(y))
         text.setFont(QFont("Arial", self.fsize - 2))
         text.setParentItem(self.item)
         tw = text.boundingRect().width()
         max_w = tw if tw > max_w else max_w
         th = text.boundingRect().height()
         # Center text according to masterItem size
         text.setPos(-tw - 5, self.coordY(y) - th / 2)
     if self.ylabel:
         text = QGraphicsSimpleTextItem(self.ylabel)
         text.setFont(QFont("Arial", self.fsize - 1))
         text.setParentItem(self.item)
         text.rotate(-90)
         tw = text.boundingRect().width()
         th = text.boundingRect().height()
         # Center text according to masterItem size
         text.setPos(-th - 5 - max_w,
                     tw / 2 + self.coordY(sum(self.ylim) / 2))
Exemplo n.º 4
0
 def draw_x_axis(self):
     #lineItem = QGraphicsLineItem(self.col_w/2,
     #                                   self.coordY(self.ylim[0])+2,
     #                                   self.width-self.col_w/2,
     #                                   self.coordY(self.ylim[0])+2,
     #                                   parent=self.item)
     #lineItem.setPen(QPen(QColor('black')))
     #lineItem.setZValue(10)
     #all_vals = list(range(0, len(self.values), 5))
     #if (len(self.values)-1)%5:
     #    all_vals += [len(self.values)-1]
     for x, lab in enumerate(self.values):
         #            lineItem = QGraphicsLineItem(0, self.coordY(self.ylim[0])+2,
         #                                               0, self.coordY(self.ylim[0])+6,
         #                                               parent=self.item)
         #            lineItem.setX(x*self.col_w + self.col_w/2)
         #            lineItem.setPen(QPen(QColor('black')))
         #            lineItem.setZValue(10)
         text = QGraphicsSimpleTextItem(str(lab))
         text.rotate(-90)
         text.setFont(QFont("Arial", self.fsize - 2))
         text.setParentItem(self.item)
         tw = text.boundingRect().height()
         # Center text according to masterItem size
         text.setPos(x * self.col_w - tw / 2 + self.col_w / 2,
                     self.coordY(self.ylim[0]))
Exemplo n.º 5
0
    def draw_x_axis(self):
        lineItem = QGraphicsLineItem(self.col_w / 2,
                                     self.coordY(self.ylim[0]) + 2,
                                     self.width - self.col_w / 2,
                                     self.coordY(self.ylim[0]) + 2,
                                     parent=self.item)
        lineItem.setPen(QPen(QColor('black')))
        lineItem.setZValue(10)
        all_vals = list(range(0, len(self.values), self.x_inter_values))
        if (len(self.values) - 1) % self.x_inter_values:
            all_vals += [len(self.values) - 1]

        hp_x = []
        if self.hp:
            for x in list(range(0, len(self.values))):
                if self.x_values[x] in self.hp:
                    hp_x.append(x)
                    if not x in all_vals:
                        all_vals += [x]
        all_vals.sort()

        for x in all_vals:
            lineItem = QGraphicsLineItem(0,
                                         self.coordY(self.ylim[0]) + 2,
                                         0,
                                         self.coordY(self.ylim[0]) + 6,
                                         parent=self.item)
            lineItem.setX(x * self.col_w + self.col_w / 2)
            lineItem.setPen(QPen(QColor('black')))
            lineItem.setZValue(10)
            if x in hp_x:
                text = QGraphicsSimpleTextItem("*" + str(self.x_values[x]))
                qfont = QFont("Arial", self.fsize - 1)
                #qfont.setBold(True)
                text.setFont(qfont)
            else:
                text = QGraphicsSimpleTextItem(" " + str(self.x_values[x]))
                text.setFont(QFont("Arial", self.fsize - 1))
            text.rotate(-90)
            text.setParentItem(self.item)
            text.setZValue(10)
            tw = text.boundingRect().width()
            th = text.boundingRect().height()
            # Center text according to masterItem size
            text.setPos(x * self.col_w - th / 2 + self.col_w / 2,
                        tw + self.coordY(self.ylim[0]) + 7)