bugfixes for scatterplot boundary miss
added method for setting axis tick font
This commit is contained in:
parent
362a0dcd04
commit
e05447de51
|
@ -58,6 +58,7 @@ class AxisItem(GraphicsWidget):
|
||||||
self.labelUnitPrefix=''
|
self.labelUnitPrefix=''
|
||||||
self.labelStyle = {}
|
self.labelStyle = {}
|
||||||
self.logMode = False
|
self.logMode = False
|
||||||
|
self.tickFont = None
|
||||||
|
|
||||||
self.textHeight = 18
|
self.textHeight = 18
|
||||||
self.tickLength = maxTickLength
|
self.tickLength = maxTickLength
|
||||||
|
@ -100,6 +101,14 @@ class AxisItem(GraphicsWidget):
|
||||||
self.picture = None
|
self.picture = None
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
def setTickFont(self, font):
|
||||||
|
self.tickFont = font
|
||||||
|
self.picture = None
|
||||||
|
self.prepareGeometryChange()
|
||||||
|
## Need to re-allocate space depending on font size?
|
||||||
|
|
||||||
|
self.update()
|
||||||
|
|
||||||
def resizeEvent(self, ev=None):
|
def resizeEvent(self, ev=None):
|
||||||
#s = self.size()
|
#s = self.size()
|
||||||
|
|
||||||
|
@ -287,14 +296,21 @@ class AxisItem(GraphicsWidget):
|
||||||
if linkedView is None or self.grid is False:
|
if linkedView is None or self.grid is False:
|
||||||
rect = self.mapRectFromParent(self.geometry())
|
rect = self.mapRectFromParent(self.geometry())
|
||||||
## extend rect if ticks go in negative direction
|
## extend rect if ticks go in negative direction
|
||||||
|
## also extend to account for text that flows past the edges
|
||||||
if self.orientation == 'left':
|
if self.orientation == 'left':
|
||||||
rect.setRight(rect.right() - min(0,self.tickLength))
|
#rect.setRight(rect.right() - min(0,self.tickLength))
|
||||||
|
#rect.setTop(rect.top() - 15)
|
||||||
|
#rect.setBottom(rect.bottom() + 15)
|
||||||
|
rect = rect.adjusted(0, -15, -min(0,self.tickLength), 15)
|
||||||
elif self.orientation == 'right':
|
elif self.orientation == 'right':
|
||||||
rect.setLeft(rect.left() + min(0,self.tickLength))
|
#rect.setLeft(rect.left() + min(0,self.tickLength))
|
||||||
|
rect = rect.adjusted(min(0,self.tickLength), -15, 0, 15)
|
||||||
elif self.orientation == 'top':
|
elif self.orientation == 'top':
|
||||||
rect.setBottom(rect.bottom() - min(0,self.tickLength))
|
#rect.setBottom(rect.bottom() - min(0,self.tickLength))
|
||||||
|
rect = rect.adjusted(-15, 0, 15, -min(0,self.tickLength))
|
||||||
elif self.orientation == 'bottom':
|
elif self.orientation == 'bottom':
|
||||||
rect.setTop(rect.top() + min(0,self.tickLength))
|
#rect.setTop(rect.top() + min(0,self.tickLength))
|
||||||
|
rect = rect.adjusted(-15, min(0,self.tickLength), 15, 0)
|
||||||
return rect
|
return rect
|
||||||
else:
|
else:
|
||||||
return self.mapRectFromParent(self.geometry()) | linkedView.mapRectToItem(self, linkedView.boundingRect())
|
return self.mapRectFromParent(self.geometry()) | linkedView.mapRectToItem(self, linkedView.boundingRect())
|
||||||
|
@ -623,6 +639,9 @@ class AxisItem(GraphicsWidget):
|
||||||
prof.mark('draw ticks')
|
prof.mark('draw ticks')
|
||||||
|
|
||||||
## Draw text until there is no more room (or no more text)
|
## Draw text until there is no more room (or no more text)
|
||||||
|
if self.tickFont is not None:
|
||||||
|
p.setFont(self.tickFont)
|
||||||
|
|
||||||
textRects = []
|
textRects = []
|
||||||
for i in range(len(tickLevels)):
|
for i in range(len(tickLevels)):
|
||||||
## Get the list of strings to display for this level
|
## Get the list of strings to display for this level
|
||||||
|
|
|
@ -202,7 +202,7 @@ class GraphicsItem(object):
|
||||||
## check global cache
|
## check global cache
|
||||||
key = (dt.m11(), dt.m21(), dt.m31(), dt.m12(), dt.m22(), dt.m32(), dt.m31(), dt.m32())
|
key = (dt.m11(), dt.m21(), dt.m31(), dt.m12(), dt.m22(), dt.m32(), dt.m31(), dt.m32())
|
||||||
pv = self._pixelVectorGlobalCache.get(key, None)
|
pv = self._pixelVectorGlobalCache.get(key, None)
|
||||||
if pv is not None:
|
if direction is None and pv is not None:
|
||||||
self._pixelVectorCache = [dt, pv]
|
self._pixelVectorCache = [dt, pv]
|
||||||
return tuple(map(Point,pv)) ## return a *copy*
|
return tuple(map(Point,pv)) ## return a *copy*
|
||||||
|
|
||||||
|
|
|
@ -620,9 +620,12 @@ class ScatterPlotItem(GraphicsObject):
|
||||||
|
|
||||||
if frac >= 1.0:
|
if frac >= 1.0:
|
||||||
## increase size of bounds based on spot size and pen width
|
## increase size of bounds based on spot size and pen width
|
||||||
px = self.pixelLength(Point(1, 0) if ax == 0 else Point(0, 1)) ## determine length of pixel along this axis
|
#px = self.pixelLength(Point(1, 0) if ax == 0 else Point(0, 1)) ## determine length of pixel along this axis
|
||||||
|
px = self.pixelVectors()[ax]
|
||||||
if px is None:
|
if px is None:
|
||||||
px = 0
|
px = 0
|
||||||
|
else:
|
||||||
|
px = px.length()
|
||||||
minIndex = np.argmin(d)
|
minIndex = np.argmin(d)
|
||||||
maxIndex = np.argmax(d)
|
maxIndex = np.argmax(d)
|
||||||
minVal = d[minIndex]
|
minVal = d[minIndex]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user