diff --git a/fluents/plots.py b/fluents/plots.py index 8dbd6c7..c3f2f77 100644 --- a/fluents/plots.py +++ b/fluents/plots.py @@ -11,7 +11,7 @@ from matplotlib.backend_bases import NavigationToolbar2,cursors from matplotlib.backends.backend_gtk import FileChooserDialog,cursord from matplotlib.widgets import SubplotTool,RectangleSelector,Lasso from matplotlib.nxutils import points_inside_poly -from matplotlib.axes import Subplot +from matplotlib.axes import Subplot, AxesImage from matplotlib.figure import Figure from matplotlib import cm,cbook from pylab import Polygon @@ -791,6 +791,33 @@ class ScatterPlot(Plot): self.canvas.draw() +class ImagePlot(Plot): + def __init__(self, dataset, **kw): + self.dataset = dataset + self.keywords = kw + + Plot.__init__(self, kw['name']) + + self.ax = self.fig.add_subplot(111) + self.ax.set_xticks([]) + self.ax.set_yticks([]) + self.ax.grid(False) + # FIXME: ax shouldn't be in kw at all + if kw.has_key('ax'): + kw.pop('ax') + + # Initial draw +# xim = AxesImage(dataset.asarray(), self.ax) + self.ax.imshow(dataset.asarray(), interpolation='nearest', aspect='auto') + + # Add canvas and show + self.add(self.canvas) + self.canvas.show() + + def get_toolbar(self): + return self._toolbar + + class NetworkPlot(Plot): def __init__(self, dataset, **kw): # Set member variables and call superclass' constructor diff --git a/workflows/test_workflow.py b/workflows/test_workflow.py index 882a91a..82bf9cf 100644 --- a/workflows/test_workflow.py +++ b/workflows/test_workflow.py @@ -29,6 +29,7 @@ class TestWorkflow (workflow.Workflow): go = workflow.Stage('go', 'Gene Ontology Data') go.add_function(GODistanceFunction()) + go.add_function(ImagePlotFunction()) self.add_stage(go) regression = workflow.Stage('regression', 'Regression') @@ -97,6 +98,14 @@ class GODistanceFunction(workflow.Function): return gene_distances +class ImagePlotFunction(workflow.Function): + def __init__(self): + workflow.Function.__init__(self, 'image', 'Show Image') + + def run(self, data): + return [plots.ImagePlot(data, name='foo')] + + class TestDataFunction(workflow.Function): def __init__(self): workflow.Function.__init__(self, 'test_data', 'Generate Test Data')