From: <kai...@t-...> - 2004-02-29 23:20:08
|
Andy Schmeder wrote: >I want to make parametric surface plots, but I can't figure out how to do >it with Gnuplot.py. I've seen plenty of examples done with gnuplot >functions, but... how to provide my own data? > >I can do something like this: (pseudocode) > >u = aspan(-0.5*Pi, 0.5*Pi, 100) >v = aspan(0, 2.0*Pi, 100) >uv = cartesian_product(u, v) >g('set parametric') >g.splot(GridData(cos(uv[0])*cos(uv[1]), cos(uv[0])*sin(uv[1]), sin(uv[0]), >type='lines')) > >Sure enough, it plots a sphere as expected, but its a line trace not a >true surface, e.g. it can't hide backfaces... > > I think you are just missing g("set hidden"). The following plots a sphere for me with hidden-line removal: import math import Gnuplot, Numeric, raster from Numeric import NewAxis theta = raster.raster(0, math.pi, 18, 0, 19) phi = raster.raster(0, 2.0 * math.pi, 36, 0, 37) xyz = Numeric.zeros((len(theta), len(phi), 3,), Numeric.Float64) xyz[:,:,0] = Numeric.sin(theta[:, NewAxis]) * Numeric.cos(phi[NewAxis, :]) xyz[:,:,1] = Numeric.sin(theta[:, NewAxis]) * Numeric.sin(phi[NewAxis, :]) xyz[:,:,2] = Numeric.cos(theta[:, NewAxis]) + (phi[NewAxis, :] * 0) g = Gnuplot.Gnuplot() g('set parametric') g('set hidden') g('set data style lines') g.splot(xyz) raw_input("Press return to continue") Hope this helps, Michael -- Michael Haggerty mh...@al... |