# Comparison of plotting packages

I was wondering what some differences and relation between common plotting packages/environment:

• `picture` environment
• PGF/TikZ
• PSTricks
• and some others that are also common but I don't know yet

for choosing when to choose which, considering:

1. are their purposes different or the same?
2. which one is more comprehensive, and which more easy to learn, and which get the best balance between?
3. is some extension of some other?
-
if you want an objective answer you need a person who has experiences with all packages and is familiar with them on the same level ... I didn't know any ... –  Herbert Apr 13 '11 at 20:45
I wouldn't use the `picture` environment for new code. TikZ and PSTricks are much more powerful. Personally I tend to TikZ but understand people which prefer PSTricks. –  Martin Scharrer Apr 13 '11 at 21:06
For all diagrams and graphs stuf, xypic is very good. But the syntax is very special –  Matsaya Apr 13 '11 at 21:40

For powerful graphics I would recommend Asymptote. It has a C++ type object orientated syntax and is not that difficult to learn (I can still not figure out any the tricks of TikZ ;-) I would say some of the main strong points are (but look at the gallery on the webpage):

• Full math and linear algebra engin
• Full 3D including active 3D pictures in PDF
• Use LaTeX to set all text and math
• It can be inlined in Latex but is normaly better to use it for standalone graphics.

It is also very good with large data sets and the manupulation thereof. I have used one graph template for all the graphs in my PhD to obtain the same sizes, line thickness, markers, etc. It is also fairly easy to do the figure below where the data was imported from a Discrete element Simulation and manipulated in Asymptote

-
Oh wow, that looks awesome! Is the 3D view of the balls generated just from the data that is plotted on the left (so just "ball number - y coordinate" pairs)? –  Jake Apr 14 '11 at 22:43
@Jake: No, it is the other way round. The ball positions are generated with DEM, the PFC3D software in particular. It is then imported into Asymptote to generate both the figures. –  Danie Els Apr 15 '11 at 1:31

I have used pstricks for years, and am now using TiKZ. I would say they are probably closely equivalent in terms of functionality, but that TiKZ is better designed, and has a more cohesive structure. For example, plotting in pstricks requires you to use PostScript:

`````` \psplot{-2}{3.25}{x dup mul 2 sub x mul 4 add sqrt neg}
``````

but in TiKZ you can use a more standard notation:

`````` \draw[domain=-2:3.25] plot (\x,{-sqrt(\x*(\x^2-2)+4)});
``````

The method in which parameters are passed to functions is the same for all functions in TiKZ. If you are used to using pstricks there's probably not much reason to change (unless, like me, you just want to), but if you are starting out, wondering which to use, I would go for TiKZ.

-
@Alasdir: as I already wrote, people who have knowledge of both are rare ... `\psplot[algebraic]{-2}{-3.25}{-sqrt(x*(x^2-2)+4)}` is what I do! –  Herbert Apr 14 '11 at 6:14

If you use `pgfplots`, you can compile with `pdflatex`. It takes quite long to evaluate the function, so it might be better if you let gnuplot do the computation for you and call gnuplot using `pdflatex -shell-escape` as described in the manual. Gnuplot also adds more functions for use, for example the inverse hyperbolic functions.

If you use `pst-plot` and `pst-3dplot`, you must compile with `latex`+`dvips`+`ps2pdf`, or use `auto-pst-pdf` to use `pdflatex -shell-escape`. But you have access to more functions internally using `pst-math` and `pst-func`. You can use algebraic notation in addition to Reverse Polish Notation.

You may also want to take a look at `metapost` and `asymptote`, which come with their own mathematical engines and produce EPS figures by default for inclusion into your document. The learning curve is steeper here though.

For `metapost` you may have to manually define certain common functions with the built-in ones before using them, while `asymptote` has the greatest 3D capabilities among them all.

-
I always use `xelatex' or the script `pst2pdf` ... and not the sequence `latex`, `dvips`, `ps2pdf` –  Herbert Apr 14 '11 at 6:16

I only have first hand experience with PSTricks and PGF/TikZ. PS Tricks is more capable for plotting functions---especially when one accounts for the various extensions that exist for it (such as the 3d plots extension). The principal downsides to PSTricks are that (i) you can't use PDF LaTeX and (ii) mathematical function entry uses reverse Polish notation (RPN), which is not very intuitive.

TikZ works with PDFLaTeX, which is a big plus for me. Drawing in TikZ is structured around nodes, which I found very unintuitive for the longest time. Once you get used to this convention, though, they help you to achieve a lot of simple tasks (such as connecting two objects with an arrow, or labeling that arrow) very easily. Plotting with TikZ (via PGFPlots) is still capable, and this is now my usual solution.

The kTikZ/qTikZ application gives you a way to edit your PGF/TikZ figures in near-real time, which makes the process of learning the language much less onerous.

Both PSTricks and TikZ match the fonts with the rest of your document (especially important is that they get the font size right). They are also invoked by embedding the figures' code within your LaTeX file---I like the fact that this gives me a pretty self-contained docuemnt.

In my view, the PSTricks manual is better for looking up the solutions to specific problems. The TikZ manual is structured around tutorials that are great for learning the language, but less helpful if you want to quickly learn how to do something very specific. PGFplots has a separate manual which is more like the PSTricks one in style. In any event, all of the manuals are very useful.

Another option is GNUPlot, which can also be made to work with inline code via the gnuplottex package. Passing everything out to an external application before bringing it back into LaTeX always seemed a bit clunky to me though and so I have abandoned this solution.

-
RPN is no longer a problem because `algebraic` option has been added long time ago. –  cyanide-based food Apr 12 '13 at 15:43