Changeset 8254:ec85c089243c in orange


Ignore:
Timestamp:
08/22/11 13:54:04 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
c4d94228cb5e75841a703b929d67373ab781830d
Message:

Improve axis title position and plot margins so that titles don't get obscured by a docked legend

Location:
orange/OrangeWidgets/plot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/plot/owaxis.py

    r8244 r8254  
    3636from math import * 
    3737 
    38 from PyQt4.QtGui import QGraphicsItem, QGraphicsLineItem, QGraphicsTextItem, QPainterPath, QGraphicsPathItem, QGraphicsScene, QTransform, QGraphicsRectItem, QPen 
     38from PyQt4.QtGui import QGraphicsItem, QGraphicsLineItem, QGraphicsTextItem, QPainterPath, QGraphicsPathItem, QGraphicsScene, QTransform, QGraphicsRectItem, QPen, QFontMetrics 
    3939from PyQt4.QtCore import QLineF, QPointF, qDebug, QRectF, Qt 
    4040 
     
    151151            offset = self.title_margin 
    152152        elif self._ticks: 
    153             offset = 50 
    154         else: 
    155             offset = 20 
     153            if self.id in YAxes or self.always_horizontal_text: 
     154                offset = 50 
     155            else: 
     156                offset = 35 
     157        else: 
     158            offset = 10 
    156159        if self.title_above: 
    157             title_pos = title_pos + (v.p2() - v.p1())*(offset) 
     160            title_pos = title_pos + (v.p2() - v.p1())*(offset + QFontMetrics(self.title_item.font()).height()) 
    158161        else: 
    159162            title_pos = title_pos - (v.p2() - v.p1())*offset 
  • orange/OrangeWidgets/plot/owplot.py

    r8252 r8254  
    345345 
    346346        self.axis_margin = 50 
     347        self.y_axis_extra_margin = 30 
    347348        self.title_margin = 40 
    348         self.graph_margin = 20 
     349        self.graph_margin = 10 
    349350         
    350351        self.mainTitle = None 
     
    957958        if yLeft in self.axes and self.axes[yLeft].isVisible(): 
    958959            left_rect = QRectF(graph_rect) 
    959             left = graph_rect.left() + margin 
     960            left = graph_rect.left() + margin + self.y_axis_extra_margin 
    960961            left_rect.setRight(left) 
    961962            graph_rect.setLeft(left) 
     
    967968        if yRight in self.axes and self.axes[yRight].isVisible(): 
    968969            right_rect = QRectF(graph_rect) 
    969             right = graph_rect.right() - margin 
     970            right = graph_rect.right() - margin - self.y_axis_extra_margin 
    970971            right_rect.setLeft(right) 
    971972            graph_rect.setRight(right) 
Note: See TracChangeset for help on using the changeset viewer.