Added ImagePlot, which displays a dataset as an image.
This commit is contained in:
parent
33c51505c4
commit
c3c6e85044
@ -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
|
||||
|
@ -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')
|
||||
|
Reference in New Issue
Block a user