Files
@ 528140423e49
Branch filter:
Location: volker/graph_components/src/graph_ZCA/app.py - annotation
528140423e49
1.4 KiB
text/x-python
ALso change of the tickmark component
7aab6dba2515 7aab6dba2515 7aab6dba2515 528140423e49 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 528140423e49 528140423e49 528140423e49 528140423e49 528140423e49 528140423e49 528140423e49 528140423e49 528140423e49 528140423e49 528140423e49 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 |
from zope.interface import implements
from graph_ZCA.components import BaseComponent, Image, Axis, AxisComponent, ViewBox, TickLabelComponent
from graph_ZCA.interfaces import IAxis, IViewBox, IBaseComponent
from zope.component import getGlobalSiteManager, adapts
gsm = getGlobalSiteManager()
class IPlotImage(IBaseComponent):
"""
Component to plot a 2d graph of a given image
"""
class PlotImage( BaseComponent):
"""
Makes a 2D plot for an image
"""
implements(IPlotImage)
def __init__(self, parent):
super(PlotImage, self).__init__(parent)
self.vb = ViewBox(self)()
x_axis = Axis(self.vb)()
x_axis.orientation='bottom'
x_axis.start=0
x_axis.end=8
y_axis = Axis(self.vb)()
y_axis.orientation='left'
y_axis.start=-5
y_axis.end=3
self.vb.addItem( x_axis )
self.vb.addItem( y_axis )
def render(self):
return self.vb.render()
class NewAxisComponent(AxisComponent):
adapts(IViewBox)
gsm.registerAdapter(NewAxisComponent)
class NewTickLabelComponent(TickLabelComponent):
adapts(IAxis)
def render(self):
return " ".join([ "q%i" % i for i in range(self.axis.start, self.axis.end)])
gsm.registerAdapter(NewTickLabelComponent)
image_data = [1,2,3,4]
plot = PlotImage( None)
image = Image(plot.vb)(image_data)
plot.vb.addItem(image)
print( plot.render())
|