Previous topic

Plot canvas example

Next topic

Input device driver example

This Page

Plot example¶

from terapy.plot.base import Plot

class PlotExample(Plot):
   """

       Example of Plot class

   """
   def __init__(self, canvas=None, array=None):
       """

           Initialization.

           Parameters:
               canvas    -    parent canvas (PlotCanvas)
               array     -    plotted data array (DataArray)

       """
       Plot.__init__(self, canvas, array)
       self.plot = None
       self.array = array
       self.SetData(array)

   def SetData(self, array):
       """

           Set plot data.

           Parameters:
               data     -    data array (DataArray)

       """
       # Insert here what should be done to set plot data from given DataArray.
       # DataArray shape, data and coords variables may be useful here.
       # See DataArray documentation for details.
       pass

   def GetData(self):
       """

           Get plot data.

           Output:
               data array (DataArray)

       """
       return self.array

   def SetColor(self, col):
       """

           Set plot color.

           Parameters:
               col    -    color (wx.Color)

       """
       Plot.SetColor(self, col)

   def Delete(self):
       """

           Delete plot.

       """
       # Insert here what should be done when plot is deleted.
       self.canvas.RemovePlot(self)

   def SetName(self, name="Plot"):
       """

           Set plot name.

           Parameters:
               name    -    name (str)

       """
       self.name = name # don't do anything with that at the moment (may be for legend)