PyX — Example: 3dgraphs/surface.py

0.2 KB
189.5 KB
26.6 KB
90.3 KB
45.8 KB
142.0 KB

Simple 3d surface

surface.png
#!/usr/bin/env python
from pyx import *

g = graph.graphxyz(size=4, x2=None, y2=None)
g.plot(graph.data.file("surface.dat", x=1, y=2, z=3), [graph.style.surface()])
g.writeEPSfile("surface")
g.writePDFfile("surface")
g.writeSVGfile("surface")

Description

This first simple example provides data for the x, y and z coordinates. PyX creates a rectangular grid from the data from the first two coordinates without relying on a special ordering of the data. A missing point will create a hole in the surface.

The surface is plotted using a mesh. In case of a huge number of data points, you may want to replace the mesh by a bitmap rasterized on a different (i.e. lower) resolution. This can reduce the file size and may also resolve various printing problems (unfortunately those are quite common with mesh data). To enable the mesh by bitmap replacement feature use the option meshasbitmap (together with its meshasbitmapresolution option)::

g.writeEPSfile(write_meshasbitmap=True)
g.writePDFfile(write_meshasbitmap=True)

The underlying rectangular grid is created by the gridpos style. By changing its parameters you can also create the base rectangular grid from others than the first two coordinates.