예제 #1
0
파일: canvas2d.py 프로젝트: vpaeder/terapy
    def __init__(self, parent=None, id=-1, xlabel=AxisInfos("Delay",du["time"]), ylabel=AxisInfos("Distance",du["length"]), xscale="linear", yscale="linear"):
        """
        
            Initialization.
            
            Parameters:
                parent    -    parent window (wx.Window)
                id        -    id (int)
                xlabel    -    label and units of abscissa axis (terapy.axedit.AxisInfos)
                ylabel    -    label and units of ordinate axis (terapy.axedit.AxisInfos)
                xscale    -    abscissa scale type (linear or log)
                yscale    -    ordinate scale type (linear or log)
        
        """
        wxmpl.PlotPanel.__init__(self,parent,id)
        PlotCanvas.__init__(self,parent,id)
        
        fig = self.get_figure()
        self.axes = fig.gca()
        self.axes.grid(True)
        self.axes.set_autoscale_on(True)
        self.axes.set_xscale(xscale)
        self.axes.set_yscale(yscale)
        
        # must make a copy of labels, otherwise same instance is used for every plot
        xlabel = xlabel.copy()
        ylabel = ylabel.copy()

        # re-format axis units into current default units 
        xlabel.units = FormatUnits(xlabel.units)
        ylabel.units = FormatUnits(ylabel.units)
        for x in [xlabel,ylabel]: x.units._magnitude = 1.0
        self.labels = [xlabel, ylabel]
        self.SetLabels()
        
        self.dim = 2
        self.set_zoom(False)
        self.set_location(False)
        self.set_selection(False)
        # generate colormap
        cdict = {'red': ((0.0, 0.0, 0.0),(0.5, 1.0, 1.0),(1.0, 1.0, 0.0)),
                'green': ((0.0, 0.0, 0.0),(0.5, 1.0, 1.0),(1.0, 0.0, 0.0)),
                'blue': ((0.0, 0.0, 1.0),(0.5, 1.0, 1.0),(1.0, 0.0, 0.0))}
        self._2d_cmap = LinearSegmentedColormap('my_colormap',cdict,256)        
        cdict = {'red': ((0.0, 0.0, 1.0),(1.0, 1.0, 0.0)),
                'green': ((0.0, 0.0, 1.0),(1.0, 0.0, 0.0)),
                'blue': ((0.0, 0.0, 1.0),(1.0, 0.0, 0.0))}
        self._2d_cmap_pos = LinearSegmentedColormap('my_colormap_pos',cdict,256)
        
        cdict = {'red': ((0.0, 0.0, 0.0),(1.0, 1.0, 0.0)),
                'green': ((0.0, 0.0, 0.0),(1.0, 1.0, 0.0)),
                'blue': ((0.0, 0.0, 1.0),(1.0, 1.0, 0.0))}
        self._2d_cmap_neg = LinearSegmentedColormap('my_colormap_neg',cdict,256)

        # send color change event to notify history from change
        pub.sendMessage("plot.color_change")

        self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftClick, self)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftClick, self)
예제 #2
0
 def __init__(
     self, parent=None, id=-1, xlabel="Delay (ps)", ylabel="Distance (um)", xscale="linear", yscale="linear"
 ):
     """
     
         Initialization.
         
         Parameters:
             parent    -    parent window (wx.Window)
             id        -    id (int)
             xlabel    -    label of abscissa axis (str)
             ylabel    -    label of ordinate axis (str)
             xscale    -    abscissa scale type (linear or log)
             yscale    -    ordinate scale type (linear or log)
     
     """
     PlotCanvas.__init__(self, parent, id, xlabel, ylabel, xscale, yscale)
예제 #3
0
파일: canvas1d.py 프로젝트: vpaeder/terapy
 def __init__(self, parent=None, id=-1, xlabel=AxisInfos("Delay",du["time"]), ylabel=AxisInfos("Signal",du["voltage"]), xscale="linear", yscale="linear"):
     """
     
         Initialization.
         
         Parameters:
             parent    -    parent window (wx.Window)
             id        -    id (int)
             xlabel    -    label and units of abscissa axis (terapy.axedit.AxisInfos)
             ylabel    -    label and units of ordinate axis (terapy.axedit.AxisInfos)
             xscale    -    abscissa scale type (linear or log)
             yscale    -    ordinate scale type (linear or log)
     
     """
     wxmpl.PlotPanel.__init__(self,parent,id)
     PlotCanvas.__init__(self,parent,id)
     
     fig = self.get_figure()
     self.axes = fig.gca()
     self.axes.grid(True)
     self.axes.set_autoscale_on(True)
     self.axes.set_xscale(xscale)
     self.axes.set_yscale(yscale)
     
     # must make a copy of labels, otherwise same instance is used for every plot
     xlabel = xlabel.copy()
     ylabel = ylabel.copy()
     
     # re-format axis units into current default units 
     xlabel.units = FormatUnits(xlabel.units)
     ylabel.units = FormatUnits(ylabel.units)
     for x in [xlabel,ylabel]: x.units._magnitude = 1.0
     self.labels = [xlabel, ylabel]
     self.SetLabels()
     
     self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftClick, self)
     self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftClick, self)
     self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightClick, self)