From baa6c4b82cbe4f4f6c277524bb0a66862af062ff Mon Sep 17 00:00:00 2001 From: Mikhail Terekhov Date: Mon, 20 Jan 2014 22:15:14 -0500 Subject: [PATCH] Fix metaarray import in MultiPlotWidget.py example and MultiPlotItem.py --- examples/MultiPlotWidget.py | 6 +++--- pyqtgraph/graphicsItems/MultiPlotItem.py | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/MultiPlotWidget.py b/examples/MultiPlotWidget.py index 28492f64..28d4f2ee 100644 --- a/examples/MultiPlotWidget.py +++ b/examples/MultiPlotWidget.py @@ -10,11 +10,11 @@ from pyqtgraph.Qt import QtGui, QtCore import pyqtgraph as pg from pyqtgraph import MultiPlotWidget try: - from metaarray import * + from pyqtgraph.metaarray import * except: print("MultiPlot is only used with MetaArray for now (and you do not have the metaarray package)") exit() - + app = QtGui.QApplication([]) mw = QtGui.QMainWindow() mw.resize(800,800) @@ -22,7 +22,7 @@ pw = MultiPlotWidget() mw.setCentralWidget(pw) mw.show() -ma = MetaArray(random.random((3, 1000)), info=[{'name': 'Signal', 'cols': [{'name': 'Col1'}, {'name': 'Col2'}, {'name': 'Col3'}]}, {'name': 'Time', 'vals': linspace(0., 1., 1000)}]) +ma = MetaArray(random.random((3, 1000)), info=[{'name': 'Signal', 'cols': [{'name': 'Col1'}, {'name': 'Col2'}, {'name': 'Col3'}]}, {'name': 'Time', 'values': linspace(0., 1., 1000)}]) pw.plot(ma) ## Start Qt event loop unless running in interactive mode. diff --git a/pyqtgraph/graphicsItems/MultiPlotItem.py b/pyqtgraph/graphicsItems/MultiPlotItem.py index d20467a9..3ae1be5b 100644 --- a/pyqtgraph/graphicsItems/MultiPlotItem.py +++ b/pyqtgraph/graphicsItems/MultiPlotItem.py @@ -9,23 +9,23 @@ from numpy import ndarray from . import GraphicsLayout try: - from metaarray import * + from ..metaarray import * HAVE_METAARRAY = True except: #raise HAVE_METAARRAY = False - + __all__ = ['MultiPlotItem'] class MultiPlotItem(GraphicsLayout.GraphicsLayout): """ Automaticaly generates a grid of plots from a multi-dimensional array """ - + def plot(self, data): #self.layout.clear() self.plots = [] - + if HAVE_METAARRAY and (hasattr(data, 'implements') and data.implements('MetaArray')): if data.ndim != 2: raise Exception("MultiPlot currently only accepts 2D MetaArray.") @@ -53,12 +53,12 @@ class MultiPlotItem(GraphicsLayout.GraphicsLayout): title = info['name'] if 'units' in info: units = info['units'] - + pi.setLabel('left', text=title, units=units) - + else: raise Exception("Data type %s not (yet?) supported for MultiPlot." % type(data)) - + def close(self): for p in self.plots: p[0].close()