Exemplo n.º 1
0
    def plot(self, x_range = [0, 0], y_range = [0, 0], x_label = "", y_label = "", title = "", scale = "OD", legend = "", new_figure = True):
        
        """
        Plot the linear spectrum.
        
        CHANGELOG:
        2011/xx/xx/RB: started
        2012/08/03/RB: changes
        
        INPUT:
        - x_range (list with 2 elements): range for the frequency axis. Set to [0,0] for the full range
        - y_range  (list with 2 elements): range for the optical density. Set to [0,0] for the full range
        - x_label (string): set the x_label. 
        - y_label (string): set the label for the y-axis. Default is OD.
        - title (string): set the title
        - scale (string): default is 'OD', alternatively: 'EC' for extinction coefficient. You should have set self.concentration and self.pathlength.
        - new_figure (BOOL): If set to True, it will call plt.figure(), plt.plot() and plt.show(). If set to False, it will only call plt.plot() and you need to call plt.figure() and plt.show() yourself. Usefull if you want to have sub-plots
        """
        # data = (self.s[0])[::-1]
        # y_label = "Absorption (OD)"
        
        print("plot...")
        
        if type(scale) == float:
            print("float")
            data = self.s[0] * scale
            if y_label == "":
                y_label = "Absorption (AU)"
            
        elif scale == "OD":
            data = self.s[0]
            if y_label == "":
                y_label = "Absorption (OD)"
            print("OD")
        elif scale == "EC":
            data = self.s[0] / (100 * self.concentration * self.pathlength)
            if y_label == "":
                y_label = "Extinction Coefficient (M-1cm-1)"
            print("EC")
        
        axis = self.s_axis[0]

        if title == "": 
            title = self.objectname
                    
        if x_label == "":
            x_label = self.s_units[0]

                
        
        P.linear(data, axis, x_range = x_range, y_range = y_range, x_label = x_label, y_label = y_label, title = title, legend = legend, new_figure = new_figure)