From ee89b291dcbbcdec9429f64b2de4eeecedcde75b Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Thu, 28 Mar 2013 12:34:17 -0400 Subject: [PATCH] Axis line can optionally stop at the last tick --- pyqtgraph/graphicsItems/AxisItem.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pyqtgraph/graphicsItems/AxisItem.py b/pyqtgraph/graphicsItems/AxisItem.py index bf3c8743..e31030df 100644 --- a/pyqtgraph/graphicsItems/AxisItem.py +++ b/pyqtgraph/graphicsItems/AxisItem.py @@ -383,7 +383,8 @@ class AxisItem(GraphicsWidget): picture = QtGui.QPicture() painter = QtGui.QPainter(picture) specs = self.generateDrawSpecs(painter) - self.drawPicture(painter, *specs) + if specs is not None: + self.drawPicture(painter, *specs) finally: painter.end() self.picture = picture @@ -646,12 +647,16 @@ class AxisItem(GraphicsWidget): ## determine mapping between tick values and local coordinates dif = self.range[1] - self.range[0] - if axis == 0: - xScale = -bounds.height() / dif - offset = self.range[0] * xScale - bounds.height() + if dif == 0: + xscale = 1 + offset = 0 else: - xScale = bounds.width() / dif - offset = self.range[0] * xScale + if axis == 0: + xScale = -bounds.height() / dif + offset = self.range[0] * xScale - bounds.height() + else: + xScale = bounds.width() / dif + offset = self.range[0] * xScale xRange = [x * xScale - offset for x in self.range] xMin = min(xRange)