diff --git a/examples/Plotting.py b/examples/Plotting.py index a41fcd1e..7842ad3d 100644 --- a/examples/Plotting.py +++ b/examples/Plotting.py @@ -45,6 +45,9 @@ p5 = win.addPlot(title="Scatter plot, axis labels, log scale") x = np.random.normal(size=1000) * 1e-5 y = x*1000 + 0.005 * np.random.normal(size=1000) y -= y.min()-1.0 +mask = x > 1e-15 +x = x[mask] +y = y[mask] p5.plot(x, y, pen=None, symbol='t', symbolPen=None, symbolSize=10, symbolBrush=(100, 100, 255, 50)) p5.setLabel('left', "Y Axis", units='A') p5.setLabel('bottom', "Y Axis", units='s') diff --git a/examples/ScatterPlot.py b/examples/ScatterPlot.py index 9baf5cd3..03e849ad 100644 --- a/examples/ScatterPlot.py +++ b/examples/ScatterPlot.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- -import sys, os ## Add path to library (just for examples; you do not need this) -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..')) +import initExample from pyqtgraph.Qt import QtGui, QtCore import pyqtgraph as pg diff --git a/examples/__main__.py b/examples/__main__.py index 40fbb5e9..87673208 100644 --- a/examples/__main__.py +++ b/examples/__main__.py @@ -182,6 +182,7 @@ def testFile(name, f, exe, lib, graphicsSystem=None): code = """ try: %s + import initExample import pyqtgraph as pg %s import %s diff --git a/examples/initExample.py b/examples/initExample.py index 6ee9db27..204a1ead 100644 --- a/examples/initExample.py +++ b/examples/initExample.py @@ -16,7 +16,6 @@ if not hasattr(sys, 'frozen'): sys.path.remove(p) sys.path.insert(0, p) - ## should force example to use PySide instead of PyQt if 'pyside' in sys.argv: from PySide import QtGui diff --git a/pyqtgraph/graphicsItems/AxisItem.py b/pyqtgraph/graphicsItems/AxisItem.py index 7be3e30f..aba5fa8c 100644 --- a/pyqtgraph/graphicsItems/AxisItem.py +++ b/pyqtgraph/graphicsItems/AxisItem.py @@ -350,9 +350,7 @@ class AxisItem(GraphicsWidget): ## decide optimal minor tick spacing in pixels (this is just aesthetics) pixelSpacing = np.log(size+10) * 5 - optimalTickCount = size / pixelSpacing - if optimalTickCount < 1: - optimalTickCount = 1 + optimalTickCount = max(2., size / pixelSpacing) ## optimal minor tick spacing optimalSpacing = dif / optimalTickCount @@ -366,12 +364,21 @@ class AxisItem(GraphicsWidget): while intervals[minorIndex+1] <= optimalSpacing: minorIndex += 1 - return [ + levels = [ (intervals[minorIndex+2], 0), (intervals[minorIndex+1], 0), #(intervals[minorIndex], 0) ## Pretty, but eats up CPU ] + ## decide whether to include the last level of ticks + minSpacing = min(size / 20., 30.) + maxTickCount = size / minSpacing + if dif / intervals[minorIndex] <= maxTickCount: + levels.append((intervals[minorIndex], 0)) + return levels + + + ##### This does not work -- switching between 2/5 confuses the automatic text-level-selection ### Determine major/minor tick spacings which flank the optimal spacing. #intervals = np.array([1., 2., 5., 10., 20., 50., 100.]) * p10unit @@ -587,7 +594,7 @@ class AxisItem(GraphicsWidget): ticks = tickLevels[i][1] ## length of tick - tickLength = self.tickLength / ((i*1.0)+1.0) + tickLength = self.tickLength / ((i*0.5)+1.0) lineAlpha = 255 / (i+1) if self.grid is not False: diff --git a/pyqtgraph/graphicsItems/PlotCurveItem.py b/pyqtgraph/graphicsItems/PlotCurveItem.py index d035a0e4..c54671bb 100644 --- a/pyqtgraph/graphicsItems/PlotCurveItem.py +++ b/pyqtgraph/graphicsItems/PlotCurveItem.py @@ -149,39 +149,6 @@ class PlotCurveItem(GraphicsObject): self.invalidateBounds() self.update() - #def setColor(self, color): - #self.pen.setColor(color) - #self.update() - - #def setAlpha(self, alpha, auto): - #self.opts['alphaHint'] = alpha - #self.opts['alphaMode'] = auto - #self.update() - - #def setSpectrumMode(self, mode): - #self.opts['spectrumMode'] = mode - #self.xDisp = self.yDisp = None - #self.path = None - #self.update() - - #def setLogMode(self, mode): - #self.opts['logMode'] = mode - #self.xDisp = self.yDisp = None - #self.path = None - #self.update() - - #def setPointMode(self, mode): - #self.opts['pointMode'] = mode - #self.update() - - - #def setDownsampling(self, ds): - #if self.opts['downsample'] != ds: - #self.opts['downsample'] = ds - #self.xDisp = self.yDisp = None - #self.path = None - #self.update() - def setData(self, *args, **kargs): """ ============== ======================================================== @@ -483,25 +450,6 @@ class PlotCurveItem(GraphicsObject): self.path = None #del self.xData, self.yData, self.xDisp, self.yDisp, self.path - #def mousePressEvent(self, ev): - ##GraphicsObject.mousePressEvent(self, ev) - #if not self.clickable: - #ev.ignore() - #if ev.button() != QtCore.Qt.LeftButton: - #ev.ignore() - #self.mousePressPos = ev.pos() - #self.mouseMoved = False - - #def mouseMoveEvent(self, ev): - ##GraphicsObject.mouseMoveEvent(self, ev) - #self.mouseMoved = True - ##print "move" - - #def mouseReleaseEvent(self, ev): - ##GraphicsObject.mouseReleaseEvent(self, ev) - #if not self.mouseMoved: - #self.sigClicked.emit(self) - def mouseClickEvent(self, ev): if not self.clickable or ev.button() != QtCore.Qt.LeftButton: return diff --git a/pyqtgraph/graphicsItems/PlotDataItem.py b/pyqtgraph/graphicsItems/PlotDataItem.py index e46279d7..8e6162f2 100644 --- a/pyqtgraph/graphicsItems/PlotDataItem.py +++ b/pyqtgraph/graphicsItems/PlotDataItem.py @@ -164,6 +164,7 @@ class PlotDataItem(GraphicsObject): self.opts['fftMode'] = mode self.xDisp = self.yDisp = None self.updateItems() + self.informViewBoundsChanged() def setLogMode(self, xMode, yMode): if self.opts['logMode'] == [xMode, yMode]: @@ -171,6 +172,7 @@ class PlotDataItem(GraphicsObject): self.opts['logMode'] = [xMode, yMode] self.xDisp = self.yDisp = None self.updateItems() + self.informViewBoundsChanged() def setPointMode(self, mode): if self.opts['pointMode'] == mode: diff --git a/pyqtgraph/multiprocess/remoteproxy.py b/pyqtgraph/multiprocess/remoteproxy.py index ee5a0d6c..94cc6048 100644 --- a/pyqtgraph/multiprocess/remoteproxy.py +++ b/pyqtgraph/multiprocess/remoteproxy.py @@ -114,7 +114,7 @@ class RemoteEventHandler(object): result = None try: cmd, reqId, nByteMsgs, optStr = self.conn.recv() ## args, kwds are double-pickled to ensure this recv() call never fails - except EOFError, IOError: + except (EOFError, IOError): ## remote process has shut down; end event loop raise ClosedError() #print os.getpid(), "received request:", cmd, reqId @@ -124,7 +124,7 @@ class RemoteEventHandler(object): for i in range(nByteMsgs): try: byteData.append(self.conn.recv_bytes()) - except EOFError, IOError: + except (EOFError, IOError): raise ClosedError()