Corrected handling of positional arguments in PlotCurveItem.__init__
This commit is contained in:
parent
2149f9db29
commit
d55526a787
@ -34,59 +34,39 @@ class PlotCurveItem(GraphicsObject):
|
|||||||
sigPlotChanged = QtCore.Signal(object)
|
sigPlotChanged = QtCore.Signal(object)
|
||||||
sigClicked = QtCore.Signal(object)
|
sigClicked = QtCore.Signal(object)
|
||||||
|
|
||||||
def __init__(self, x=None, y=None, fillLevel=None, copy=False, pen=None, shadowPen=None, brush=None, parent=None, clickable=False):
|
def __init__(self, *args, **kargs):
|
||||||
"""
|
"""
|
||||||
|
Forwards all arguments to :func:`setData <pyqtgraph.PlotCurveItem.setData>`.
|
||||||
|
|
||||||
|
Some extra arguments are accepted as well:
|
||||||
|
|
||||||
============== =======================================================
|
============== =======================================================
|
||||||
**Arguments:**
|
**Arguments:**
|
||||||
x, y (numpy arrays) Data to show
|
parent The parent GraphicsObject (optional)
|
||||||
pen Pen to use when drawing. Any single argument accepted by
|
|
||||||
:func:`mkPen <pyqtgraph.mkPen>` is allowed.
|
|
||||||
shadowPen Pen for drawing behind the primary pen. Usually this
|
|
||||||
is used to emphasize the curve by providing a
|
|
||||||
high-contrast border. Any single argument accepted by
|
|
||||||
:func:`mkPen <pyqtgraph.mkPen>` is allowed.
|
|
||||||
fillLevel (float or None) Fill the area 'under' the curve to
|
|
||||||
*fillLevel*
|
|
||||||
brush QBrush to use when filling. Any single argument accepted
|
|
||||||
by :func:`mkBrush <pyqtgraph.mkBrush>` is allowed.
|
|
||||||
clickable If True, the item will emit sigClicked when it is
|
clickable If True, the item will emit sigClicked when it is
|
||||||
clicked on.
|
clicked on. Defaults to False.
|
||||||
============== =======================================================
|
============== =======================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
GraphicsObject.__init__(self, parent)
|
GraphicsObject.__init__(self, kargs.get('parent', None))
|
||||||
self.clear()
|
self.clear()
|
||||||
self.path = None
|
self.path = None
|
||||||
self.fillPath = None
|
self.fillPath = None
|
||||||
self.exportOpts = False
|
self.exportOpts = False
|
||||||
self.antialias = False
|
self.antialias = False
|
||||||
|
|
||||||
if y is not None:
|
|
||||||
self.updateData(y, x)
|
|
||||||
|
|
||||||
## this is disastrous for performance.
|
## this is disastrous for performance.
|
||||||
#self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache)
|
#self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache)
|
||||||
|
|
||||||
self.metaData = {}
|
self.metaData = {}
|
||||||
self.opts = {
|
self.opts = {
|
||||||
#'spectrumMode': False,
|
'pen': fn.mkPen('w'),
|
||||||
#'logMode': [False, False],
|
|
||||||
#'downsample': False,
|
|
||||||
#'alphaHint': 1.0,
|
|
||||||
#'alphaMode': False,
|
|
||||||
'pen': 'w',
|
|
||||||
'shadowPen': None,
|
'shadowPen': None,
|
||||||
'fillLevel': fillLevel,
|
'fillLevel': None,
|
||||||
'brush': brush,
|
'brush': None,
|
||||||
}
|
}
|
||||||
self.setPen(pen)
|
self.setClickable(kargs.get('clickable', False))
|
||||||
self.setShadowPen(shadowPen)
|
self.setData(*args, **kargs)
|
||||||
self.setFillLevel(fillLevel)
|
|
||||||
self.setBrush(brush)
|
|
||||||
self.setClickable(clickable)
|
|
||||||
#self.fps = None
|
|
||||||
|
|
||||||
def implements(self, interface=None):
|
def implements(self, interface=None):
|
||||||
ints = ['plotData']
|
ints = ['plotData']
|
||||||
@ -101,41 +81,6 @@ class PlotCurveItem(GraphicsObject):
|
|||||||
|
|
||||||
def getData(self):
|
def getData(self):
|
||||||
return self.xData, self.yData
|
return self.xData, self.yData
|
||||||
#if self.xData is None:
|
|
||||||
#return (None, None)
|
|
||||||
#if self.xDisp is None:
|
|
||||||
#nanMask = np.isnan(self.xData) | np.isnan(self.yData)
|
|
||||||
#if any(nanMask):
|
|
||||||
#x = self.xData[~nanMask]
|
|
||||||
#y = self.yData[~nanMask]
|
|
||||||
#else:
|
|
||||||
#x = self.xData
|
|
||||||
#y = self.yData
|
|
||||||
#ds = self.opts['downsample']
|
|
||||||
#if ds > 1:
|
|
||||||
#x = x[::ds]
|
|
||||||
##y = resample(y[:len(x)*ds], len(x)) ## scipy.signal.resample causes nasty ringing
|
|
||||||
#y = y[::ds]
|
|
||||||
#if self.opts['spectrumMode']:
|
|
||||||
#f = fft(y) / len(y)
|
|
||||||
#y = abs(f[1:len(f)/2])
|
|
||||||
#dt = x[-1] - x[0]
|
|
||||||
#x = np.linspace(0, 0.5*len(x)/dt, len(y))
|
|
||||||
#if self.opts['logMode'][0]:
|
|
||||||
#x = np.log10(x)
|
|
||||||
#if self.opts['logMode'][1]:
|
|
||||||
#y = np.log10(y)
|
|
||||||
#self.xDisp = x
|
|
||||||
#self.yDisp = y
|
|
||||||
##print self.yDisp.shape, self.yDisp.min(), self.yDisp.max()
|
|
||||||
##print self.xDisp.shape, self.xDisp.min(), self.xDisp.max()
|
|
||||||
#return self.xDisp, self.yDisp
|
|
||||||
|
|
||||||
#def generateSpecData(self):
|
|
||||||
#f = fft(self.yData) / len(self.yData)
|
|
||||||
#self.ySpec = abs(f[1:len(f)/2])
|
|
||||||
#dt = self.xData[-1] - self.xData[0]
|
|
||||||
#self.xSpec = linspace(0, 0.5*len(self.xData)/dt, len(self.ySpec))
|
|
||||||
|
|
||||||
def dataBounds(self, ax, frac=1.0):
|
def dataBounds(self, ax, frac=1.0):
|
||||||
(x, y) = self.getData()
|
(x, y) = self.getData()
|
||||||
@ -154,12 +99,6 @@ class PlotCurveItem(GraphicsObject):
|
|||||||
else:
|
else:
|
||||||
return (scipy.stats.scoreatpercentile(d, 50 - (frac * 50)), scipy.stats.scoreatpercentile(d, 50 + (frac * 50)))
|
return (scipy.stats.scoreatpercentile(d, 50 - (frac * 50)), scipy.stats.scoreatpercentile(d, 50 + (frac * 50)))
|
||||||
|
|
||||||
#def setMeta(self, data):
|
|
||||||
#self.metaData = data
|
|
||||||
|
|
||||||
#def meta(self):
|
|
||||||
#return self.metaData
|
|
||||||
|
|
||||||
def setPen(self, *args, **kargs):
|
def setPen(self, *args, **kargs):
|
||||||
"""Set the pen used to draw the curve."""
|
"""Set the pen used to draw the curve."""
|
||||||
self.opts['pen'] = fn.mkPen(*args, **kargs)
|
self.opts['pen'] = fn.mkPen(*args, **kargs)
|
||||||
@ -219,7 +158,26 @@ class PlotCurveItem(GraphicsObject):
|
|||||||
|
|
||||||
def setData(self, *args, **kargs):
|
def setData(self, *args, **kargs):
|
||||||
"""
|
"""
|
||||||
Accepts most of the same arguments as __init__.
|
============== =======================================================
|
||||||
|
**Arguments:**
|
||||||
|
x, y (numpy arrays) Data to show
|
||||||
|
pen Pen to use when drawing. Any single argument accepted by
|
||||||
|
:func:`mkPen <pyqtgraph.mkPen>` is allowed.
|
||||||
|
shadowPen Pen for drawing behind the primary pen. Usually this
|
||||||
|
is used to emphasize the curve by providing a
|
||||||
|
high-contrast border. Any single argument accepted by
|
||||||
|
:func:`mkPen <pyqtgraph.mkPen>` is allowed.
|
||||||
|
fillLevel (float or None) Fill the area 'under' the curve to
|
||||||
|
*fillLevel*
|
||||||
|
brush QBrush to use when filling. Any single argument accepted
|
||||||
|
by :func:`mkBrush <pyqtgraph.mkBrush>` is allowed.
|
||||||
|
============== =======================================================
|
||||||
|
|
||||||
|
If non-keyword arguments are used, they will be interpreted as
|
||||||
|
setData(y) for a single argument and setData(x, y) for two
|
||||||
|
arguments.
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.updateData(*args, **kargs)
|
self.updateData(*args, **kargs)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user