# Plotting 3D polyhedra, which package?

I have been using TikZ a lot but only for 2D plots. I was hoping I could use the 3D package for plotting regions on the (x,y,z) plane given by linear inequalities (currently I'm using Mathematica for these 3D plots but I wanted to have more control over the plot options) but it seems that this is not the case.

Is there any alternative to TikZ-3D that is able to plot set of points (x,y,z) such that 0 is less or equal than min(x,0)+min(x,y,0)+z ? By that I mean: 1) Can it plot 3D level sets? and 2) If the function is a binary function: 1 in a set similar to the one described above and zero elsewhere, will it be able to do the level sets plot in minutes (say less than one hour)?

EDIT: "tikz-3dplot does not, in general, consider polygons, surfaces, or object opac- ity" so I'm changing the question to allow for gnuplot, PStricks or Asymptote (I'm not familiar with both of these packages) or any tool that allow me to control the plots specifications with greater detail.

I'm attaching a 3D plot I did with Mathematica:

• Tikz is not a particular efficient package (like a dancing bear) and how long it takes to test inequalities in 3D depends on the resolution. My advise is to solve it, then plot it. – John Kormylo May 21 '14 at 13:56
• Asymptote can do what you describe, but the result isn't pretty. In general, implicitly defined surfaces should be used only as a last resort. In this case, I recommend that you use Mathematica (or some other software capable of solving linear programming problems) to get a list of all the faces of your polyhedron; then plot those faces using any of the three packages you mention. – Charles Staats May 21 '14 at 15:30
• @CharlesStaats: Thanks that's sound the most promising idea. – Sergio Parreiras May 21 '14 at 16:07
• @CharlesStaats : would you please consider making your comment an answer? – Sergio Parreiras Jun 28 '14 at 4:13

Run with xelatex:

\documentclass{article}
\usepackage{pst-solides3d}
\begin{document}

\psset{lightsrc=viewpoint,viewpoint=30 10 10 rtp2xyz,Decran=25}
\begin{pspicture}(-5,-2)(3,4)
\psSolid[object=prisme,h=4,fillcolor=red!20,RotY=90,
ngrid=5,base=0 0 1 -1 1 1 0 1 0 0 ]% x y coordinates of the projection
\axesIIID[showOrigin=false](10,3,3)

\end{pspicture}


I recommend METAPOST to anybody interested in producing graphics to use in TeX or LaTeX documents. The reasons to prefer METAPOST over TIKZ or similar LaTeX packages are:

1. METAPOST is a full programming language aimed at producing pictures, and has a lot of interesting builtin function (path intersection, affine transformations, resolution of linear systems, and more).
2. METAPOST is not as puzzling as TeX is for novices, while METAPOST is also macro-expansion based, thinkink of it as a procedural language does not lead to such failures as it does with TeX.
3. You do not need to recompute your picture each time you compile your document. If you are using FreeBSD, Mac OS-X or any GNU/Linux system, you can use my make macros to take care of the compilation. (For detailed instructions, see Figures with METAPOST on the wiki.)
4. If you learn METAPOST, you can use its excellent mpgraph package to plot various functions.

The TeX users group has a page on its website devoted to METAPOST. The list you will find there is pretty long, so let me add that I especially like the introduction written by André Heck, you will find an example of a 3D-plot on page 54. See also Phan's propaganda for METAPOST.

You also could be interested in the answers to A good METAPOST alternative for plotting 3d surfaces.

• This answer does not address the specific question asked. I suggest you repost this answer in an appropriate question or, if necessary, ask one (e.g., "what are the advantages and disadvantages of metapost versus tikz?"). – Charles Staats May 21 '14 at 17:54
• Regarding point 3: TikZ images also don't need to be regenerated every time the document is compiled. The external library automatically generates standalone image files. – Jake May 21 '14 at 19:18