def plot(self, call_show=True): try: from jsplot import plot, show except ImportError: from pylab import plot, show odd = False for a, b, order in self.iter_elems(): fekete_points = _fekete.get_fekete_points_phys(order, a, b) if odd: format = "y-" else: format = "k-" odd = not odd plot([a, a, b, b], [0, order, order, 0], format, lw=2) if call_show: show()
def plot(self, call_show=True): try: from jsplot import plot, show except ImportError: from pylab import plot, show odd = False for n, (a, b, order) in enumerate(self._mesh.iter_elems()): fekete_points = _fekete.get_fekete_points_phys(order, a, b) vals = self._values[n] assert len(vals) == len(fekete_points) x = arange(a, b, 0.1) y = [self(_x) for _x in x] if odd: format = "g-" else: format = "r-" odd = not odd plot(x, y, format) plot(fekete_points, vals, "ko") if call_show: show()
try: from jsplot import plot, show except ImportError: from pylab import plot, show import numpy data = numpy.loadtxt("solution.gp") x = data[:, 0] y = data[:, 1] plot(x, y) show()
try: from jsplot import plot, show, grid, legend except ImportError: from pylab import plot, show, grid, legend import numpy data = numpy.loadtxt("solution.gp_0") x = data[:, 0] y = data[:, 1] label = "Pendulum angle" plot(x, y, label=label) legend() grid(True) data = numpy.loadtxt("solution.gp_1") x = data[:, 0] y = data[:, 1] label = "Angular velocity" plot(x, y, label=label) legend() grid(True) show()
try: from jsplot import plot, show, legend except ImportError: from pylab import plot, show, legend import numpy data = numpy.loadtxt("solution_ref.gp") x = data[:, 0] y = data[:, 1] plot(x, y, label="FTR array") data = numpy.loadtxt("solution.gp") x = data[:, 0] y = data[:, 1] plot(x, y, label="solution") legend() show()
try: from jsplot import plot, show, legend except ImportError: from pylab import plot, show, legend import numpy data = numpy.loadtxt("mesh.gp") x = data[:, 0] y = data[:, 1] plot(x, y, label="mesh") legend() show()
try: from jsplot import plot, show except ImportError: from pylab import plot, show import numpy data = numpy.loadtxt("solution.gp_0") x = data[:, 0] y = data[:, 1] plot(x, y, label="0") data = numpy.loadtxt("solution.gp_1") x = data[:, 0] y = data[:, 1] plot(x, y, label="1") show()
from numpy import array from jsplot import plot, show def get_data1(): x1 = 0 x2 = 3*pi d = [] for i in range(101): x = x1 + i * (x2 - x1) / 100. d.append([x, sin(x * sin(x))]) return d def get_data2(): x1 = 0 x2 = 3*pi d = [] for i in range(101): x = x1 + i * (x2 - x1) / 100. d.append([x, sin(x)]) return d d = array(get_data1()) x = d[:, 0] y = d[:, 1] plot(x, y, label="sin(x*sin(x))") d = array(get_data2()) x = d[:, 0] y = d[:, 1] plot(x, y, label="sin(x)") show()