def demo1(f=f1, nx=4, ny=3, viewx=58, viewy=345, plain_gnuplot=True): vertices, cells = mesh(nx, ny, x=[0, 1], y=[0, 1], diagonal='right') if f == 'basis': # basis function zvalues = np.zeros(vertices.shape[0]) zvalues[int(round(len(zvalues) / 2.)) + int(round(nx / 2.))] = 1 else: zvalues = fill(f1, vertices) if plain_gnuplot: plt = Gnuplotter() else: import scitools.std as plt """ if plt.backend == 'gnuplot': gpl = plt.get_backend() gpl('unset border; unset xtics; unset ytics; unset ztics') #gpl('replot') """ draw_mesh(vertices, cells, plt) draw_surface(zvalues, vertices, cells, plt) plt.axis([0, 1, 0, 1, 0, zvalues.max()]) plt.view(viewx, viewy) if plain_gnuplot: plt.savefig('tmp') else: plt.savefig('tmp.pdf') plt.savefig('tmp.eps') plt.savefig('tmp.png') plt.show()
def demo1(f=f1, nx=4, ny=3, viewx=58, viewy=345, plain_gnuplot=True): vertices, cells = mesh(nx, ny, x=[0,1], y=[0,1], diagonal='right') if f == 'basis': # basis function zvalues = np.zeros(vertices.shape[0]) zvalues[int(round(len(zvalues)/2.)) + int(round(nx/2.))] = 1 else: zvalues = fill(f1, vertices) if plain_gnuplot: plt = Gnuplotter() else: import scitools.std as plt """ if plt.backend == 'gnuplot': gpl = plt.get_backend() gpl('unset border; unset xtics; unset ytics; unset ztics') #gpl('replot') """ draw_mesh(vertices, cells, plt) draw_surface(zvalues, vertices, cells, plt) plt.axis([0, 1, 0, 1, 0, zvalues.max()]) plt.view(viewx, viewy) if plain_gnuplot: plt.savefig('tmp') else: plt.savefig('tmp.pdf') plt.savefig('tmp.eps') plt.savefig('tmp.png') plt.show()
def fill(f, vertices): values = np.zeros(vertices.shape[0]) for i, point in enumerate(vertices): values[i] = f(point[0], point[1]) return values