From ae4483bfaacba171b0350c71ef84ca471feb23c2 Mon Sep 17 00:00:00 2001 From: angulartist Date: Sun, 19 Jul 2020 15:58:13 +0200 Subject: [PATCH 1/3] Enhancement: [Issue/812]: MultiPlotItem handles pen (QPen) as a keyword argument --- pyqtgraph/graphicsItems/MultiPlotItem.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pyqtgraph/graphicsItems/MultiPlotItem.py b/pyqtgraph/graphicsItems/MultiPlotItem.py index 065a605e..dcdcf986 100644 --- a/pyqtgraph/graphicsItems/MultiPlotItem.py +++ b/pyqtgraph/graphicsItems/MultiPlotItem.py @@ -4,8 +4,8 @@ MultiPlotItem.py - Graphics item used for displaying an array of PlotItems Copyright 2010 Luke Campagnola Distributed under MIT/X11 license. See license.txt for more information. """ - from numpy import ndarray +from ..Qt import QtGui from . import GraphicsLayout from ..metaarray import * @@ -18,10 +18,20 @@ class MultiPlotItem(GraphicsLayout.GraphicsLayout): def __init__(self, *args, **kwds): GraphicsLayout.GraphicsLayout.__init__(self, *args, **kwds) self.plots = [] - - def plot(self, data): + + def plot(self, data, **kwargs): #self.layout.clear() + # extra plot parameters + extraParams = {} + + # if 'pen' provided, add it as an extra param + if 'pen' in kwargs: + pen = kwargs['pen'] + if not isinstance(pen, QtGui.QPen): + raise TypeError("Keyword argument 'pen' must be an instance of QtGui.QPen") + extraParams['pen'] = pen + if hasattr(data, 'implements') and data.implements('MetaArray'): if data.ndim != 2: @@ -38,7 +48,7 @@ class MultiPlotItem(GraphicsLayout.GraphicsLayout): self.nextRow() sl = [slice(None)] * 2 sl[ax] = i - pi.plot(data[tuple(sl)]) + pi.plot(data[tuple(sl)], **extraParams) #self.layout.addItem(pi, i, 0) self.plots.append((pi, i, 0)) info = ic[ax]['cols'][i] @@ -57,6 +67,3 @@ class MultiPlotItem(GraphicsLayout.GraphicsLayout): p[0].close() self.plots = None self.clear() - - - From 58aa9306dffb057218979553609404f5e4c02216 Mon Sep 17 00:00:00 2001 From: angulartist Date: Sun, 19 Jul 2020 19:16:07 +0200 Subject: [PATCH 2/3] Enhancement: [Issue/812]: just pass plotArgs keyword arguments --- examples/MultiPlotWidget.py | 2 +- pyqtgraph/graphicsItems/MultiPlotItem.py | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/examples/MultiPlotWidget.py b/examples/MultiPlotWidget.py index 67cb83ee..2800ee44 100644 --- a/examples/MultiPlotWidget.py +++ b/examples/MultiPlotWidget.py @@ -30,7 +30,7 @@ ma = MetaArray(data, info=[ ]}, {'name': 'Time', 'values': linspace(0., 1., 1000), 'units': 's'} ]) -pw.plot(ma) +pw.plot(ma, pen='y') ## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': diff --git a/pyqtgraph/graphicsItems/MultiPlotItem.py b/pyqtgraph/graphicsItems/MultiPlotItem.py index dcdcf986..addafde2 100644 --- a/pyqtgraph/graphicsItems/MultiPlotItem.py +++ b/pyqtgraph/graphicsItems/MultiPlotItem.py @@ -20,18 +20,8 @@ class MultiPlotItem(GraphicsLayout.GraphicsLayout): self.plots = [] - def plot(self, data, **kwargs): + def plot(self, data, **plotArgs): #self.layout.clear() - # extra plot parameters - extraParams = {} - - # if 'pen' provided, add it as an extra param - if 'pen' in kwargs: - pen = kwargs['pen'] - if not isinstance(pen, QtGui.QPen): - raise TypeError("Keyword argument 'pen' must be an instance of QtGui.QPen") - extraParams['pen'] = pen - if hasattr(data, 'implements') and data.implements('MetaArray'): if data.ndim != 2: @@ -48,7 +38,7 @@ class MultiPlotItem(GraphicsLayout.GraphicsLayout): self.nextRow() sl = [slice(None)] * 2 sl[ax] = i - pi.plot(data[tuple(sl)], **extraParams) + pi.plot(data[tuple(sl)], **plotArgs) #self.layout.addItem(pi, i, 0) self.plots.append((pi, i, 0)) info = ic[ax]['cols'][i] From 5765b0d4c24f44e2488e42bdb2dbfb5e875c94a2 Mon Sep 17 00:00:00 2001 From: angulartist Date: Sun, 19 Jul 2020 19:16:58 +0200 Subject: [PATCH 3/3] Enhancement: [Issue/812]: remove unused import --- pyqtgraph/graphicsItems/MultiPlotItem.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyqtgraph/graphicsItems/MultiPlotItem.py b/pyqtgraph/graphicsItems/MultiPlotItem.py index addafde2..588de331 100644 --- a/pyqtgraph/graphicsItems/MultiPlotItem.py +++ b/pyqtgraph/graphicsItems/MultiPlotItem.py @@ -5,7 +5,6 @@ Copyright 2010 Luke Campagnola Distributed under MIT/X11 license. See license.txt for more information. """ from numpy import ndarray -from ..Qt import QtGui from . import GraphicsLayout from ..metaarray import *