Exemplo n.º 1
0
    def plot_fixed_y(self, y_values, x_derivative=0, steps=1000, smooth=0, simple='auto', xmin="auto", xmax="auto", format=True, clear=1):
        """
        plots the data at a fixed y-value, so z vs y
        """
        if simple=='auto': simple=self.simple


        # get the min and max
        if xmin=="auto": xmin = self.xmin
        if xmax=="auto": xmax = self.xmax
        if clear: _pylab.gca().clear()

        if not type(y_values) in [type([]), type(_pylab.array([]))]: y_values = [y_values]

        for y in y_values:
            # define a new simple function to plot, then plot it
            def f(x): return self.evaluate(x, y, x_derivative, smooth, simple)
            _pylab_help.plot_function(f, xmin, xmax, steps, 0, True)

            # label it
            a = _pylab.gca()
            th = "th"
            if x_derivative == 1: th = "st"
            if x_derivative == 2: th = "nd"
            if x_derivative == 3: th = "rd"
            if x_derivative: a.set_ylabel(str(x_derivative)+th+" "+self.xlabel+" derivative of "+self.zlabel+" spline")
            else:            a.set_ylabel(self.zlabel)
            a.set_xlabel(self.xlabel)
            a.set_title(self._path+"\nSpline array plot at fixed y "+self.ylabel)
            a.get_lines()[-1].set_label("y ("+self.ylabel+") = "+str(y))
        if format: _s.format_figure()
        return a
Exemplo n.º 2
0
    def plot_fixed_x(self, x_values, x_derivative=0, steps=1000, smooth=0, simple='auto', ymin="auto", ymax="auto", format=True, clear=1):
        """
        plots the data at fixed x-value, so z vs x
        """
        if simple=='auto': simple=self.simple
        
        # get the min and max
        if ymin=="auto": ymin = self.ymin
        if ymax=="auto": ymax = self.ymax
        if clear: _pylab.gca().clear()

        if not type(x_values) in [type([]), type(_pylab.array([]))]: x_values = [x_values]

        for x in x_values:
    
            # define a new simple function to plot, then plot it
            def f(y): return self.evaluate(x, y, x_derivative, smooth, simple)
            _pylab_help.plot_function(f, ymin, ymax, steps, 0, False)

            # label it
            a = _pylab.gca()
            a.set_xlabel(self.ylabel)
            if x_derivative: a.set_ylabel(str(x_derivative)+" "+str(self.xlabel)+" derivative of "+self.zlabel)
            else:            a.set_ylabel(self.zlabel)
            a.set_title(self._path+"\nSpline array plot at fixed x = "+self.xlabel)
            a.get_lines()[-1].set_label("x ("+self.xlabel+") = "+str(x))

        if format: _s.format_figure()
        return a
Exemplo n.º 3
0
    def plot(self, derivative=0, xmin="auto", xmax="auto", steps=500, smooth=0, simple='auto', clear=True, yaxis='left'):
        if simple=='auto': simple = self.simple

        # get the min and max
        if xmin=="auto": xmin = self.xmin
        if xmax=="auto": xmax = self.xmax

        # get and clear the figure and axes
        f = _pylab.gcf()
        if clear and yaxis=='left': f.clf()

        # setup the right-hand axis
        if yaxis=='right':  a = _pylab.twinx()
        else:               a = _pylab.gca()

        # define a new simple function to plot, then plot it
        def f(x): return self.evaluate(x, derivative, smooth, simple)
        _pylab_help.plot_function(f, xmin, xmax, steps, clear, axes=a)

        # label it
        th = "th"
        if derivative == 1: th = "st"
        if derivative == 2: th = "nd"
        if derivative == 3: th = "rd"
        if derivative: self.ylabel = str(derivative)+th+" derivative of "+self.ylabel+" spline"
        a.set_xlabel(self.xlabel)
        a.set_ylabel(self.ylabel)
        a.figure.canvas.Refresh()
Exemplo n.º 4
0
    def plot_fixed_y(self,
                     y_values,
                     x_derivative=0,
                     steps=1000,
                     smooth=0,
                     simple='auto',
                     xmin="auto",
                     xmax="auto",
                     format=True,
                     clear=1):
        """
        plots the data at a fixed y-value, so z vs y
        """
        if simple == 'auto': simple = self.simple

        # get the min and max
        if xmin == "auto": xmin = self.xmin
        if xmax == "auto": xmax = self.xmax
        if clear: _pylab.gca().clear()

        if not type(y_values) in [type([]), type(_pylab.array([]))]:
            y_values = [y_values]

        for y in y_values:
            # define a new simple function to plot, then plot it
            def f(x):
                return self.evaluate(x, y, x_derivative, smooth, simple)

            _pylab_help.plot_function(f, xmin, xmax, steps, 0, True)

            # label it
            a = _pylab.gca()
            th = "th"
            if x_derivative == 1: th = "st"
            if x_derivative == 2: th = "nd"
            if x_derivative == 3: th = "rd"
            if x_derivative:
                a.set_ylabel(
                    str(x_derivative) + th + " " + self.xlabel +
                    " derivative of " + self.zlabel + " spline")
            else:
                a.set_ylabel(self.zlabel)
            a.set_xlabel(self.xlabel)
            a.set_title(self._path + "\nSpline array plot at fixed y " +
                        self.ylabel)
            a.get_lines()[-1].set_label("y (" + self.ylabel + ") = " + str(y))
        if format: _s.format_figure()
        return a
Exemplo n.º 5
0
    def plot_fixed_x(self,
                     x_values,
                     x_derivative=0,
                     steps=1000,
                     smooth=0,
                     simple='auto',
                     ymin="auto",
                     ymax="auto",
                     format=True,
                     clear=1):
        """
        plots the data at fixed x-value, so z vs x
        """
        if simple == 'auto': simple = self.simple

        # get the min and max
        if ymin == "auto": ymin = self.ymin
        if ymax == "auto": ymax = self.ymax
        if clear: _pylab.gca().clear()

        if not type(x_values) in [type([]), type(_pylab.array([]))]:
            x_values = [x_values]

        for x in x_values:

            # define a new simple function to plot, then plot it
            def f(y):
                return self.evaluate(x, y, x_derivative, smooth, simple)

            _pylab_help.plot_function(f, ymin, ymax, steps, 0, False)

            # label it
            a = _pylab.gca()
            a.set_xlabel(self.ylabel)
            if x_derivative:
                a.set_ylabel(
                    str(x_derivative) + " " + str(self.xlabel) +
                    " derivative of " + self.zlabel)
            else:
                a.set_ylabel(self.zlabel)
            a.set_title(self._path + "\nSpline array plot at fixed x = " +
                        self.xlabel)
            a.get_lines()[-1].set_label("x (" + self.xlabel + ") = " + str(x))

        if format: _s.format_figure()
        return a
Exemplo n.º 6
0
    def plot(self,
             derivative=0,
             xmin="auto",
             xmax="auto",
             steps=500,
             smooth=0,
             simple='auto',
             clear=True,
             yaxis='left'):
        if simple == 'auto': simple = self.simple

        # get the min and max
        if xmin == "auto": xmin = self.xmin
        if xmax == "auto": xmax = self.xmax

        # get and clear the figure and axes
        f = _pylab.gcf()
        if clear and yaxis == 'left': f.clf()

        # setup the right-hand axis
        if yaxis == 'right': a = _pylab.twinx()
        else: a = _pylab.gca()

        # define a new simple function to plot, then plot it
        def f(x):
            return self.evaluate(x, derivative, smooth, simple)

        _pylab_help.plot_function(f, xmin, xmax, steps, clear, axes=a)

        # label it
        th = "th"
        if derivative == 1: th = "st"
        if derivative == 2: th = "nd"
        if derivative == 3: th = "rd"
        if derivative:
            self.ylabel = str(
                derivative) + th + " derivative of " + self.ylabel + " spline"
        a.set_xlabel(self.xlabel)
        a.set_ylabel(self.ylabel)
        a.figure.canvas.Refresh()