# What are some good graphing libraries/programs for embedding in LaTeX

The de-facto plotting program for LaTeX is, AFAIA, gnuplot.

Is there such a program for drawing graphs/diagrams? I am aware of graphviz and at first glance it appears very useful, but it is missing certain basic features such as specifying multiple rank orders (arrange left to right, top to bottom... see here) or subscripts/superscripts. It apparently allows for html formatting which in theory provides for subscripts/superscripts, but it does not seem to work. dot2tex attempts to make graphviz more LaTeX friendly, but the generated graphs are not as sharp, C style comments, which are valid in graphviz files, appear to conflict with LaTeX files, even when included as a `doc` file, and I, personally, can't figure out how to embed the graph as a figure as opposed to a dangling graph.

Is there a way to address some of these shortcomings:

• no sub/superscripts
• no figures

If not, is there a way to output the file to a more LaTeX friendly format, much like gnuplot does with its latex format, such that I can use LaTeX's math mode?

EDIT here are two pictures to better describe what I mean by graphs and/or diagrams

-
Is something like `sagetex` of interest? I must admit, I'm not exactly sure what you're after, since "graphs" and "diagrams" are very general. –  Werner Feb 2 '12 at 6:26
What about proposals in Is there a pure LaTeX or TeX package for chart drawing? –  Ignasi Feb 2 '12 at 8:35
@Werner I'll include some pictures to clarify –  puk Feb 2 '12 at 8:39
Who answers the obvious? (TikZ) –  topskip Feb 2 '12 at 9:22
Too lazy to write an answer, so I'll just add two links to TeXample: texample.net/tikz/examples/tag/block-diagrams and texample.net/tikz/examples/tag/diagrams –  Torbjørn T. Feb 2 '12 at 9:31

As the commenters mentioned, TikZ can do these graphics and use the full power of LaTeX. A main advantage is that, unlike pstricks, the package works for all output drivers, most notably PS and PDF. Everything will compile with just one (or two) `latex`/`pdflatex` run(s), no extra setup required. Not to mention the plethora of features described in the excellent 700+ pages manual (with tutorial).

While we're at it, try R and its TikZ device for plotting.

-
That manual should be slapped in the face of every first year computer scientist until they adopt its style entirely! I have never seen a tutorial that great. Not on w3schools, not on wikipedia, not even in strategy guides. +1,000,000 –  puk Feb 2 '12 at 21:01

The best tool is John Hobby's MetaPost, that can use a TeX engine (with whatever format: plain, LaTeX, and so on) [or by the way a troff engine too...] for the layout of "labels", and propose all the features of a programming/scripting language METAFONT like with a PostScript output. I use this for almost all my drawings; and to create easily legends and layout for maps---MetaPost can be considered as a PostScript scripting language too; so really handy to program the customization of maps.

MetaPost is a fantastic tool. To be found in, I think, all the TeX distributions---and of course: kerTeX.

The caveat is that to "see" the result, one needs a PostScript interpreter---while with METAFONT, you have also a rasterizer. (I even think that it could be useful in the future, for kerTeX, whether to develop a "MostScript", that is a PostScript limited interpreter able to render MetaPost figures; or to add back the rasterizing capabilities of METAFONT in MetaPost to be free from the need of a PostScript interpreter (software or "hardware" [printer]).

-
Asymptote has C++-like syntax to define points by equations (like MetaPost). –  vonbrand Jan 17 '13 at 1:44

As a complement to the `tikz` libraries available, there are numerous `pstricks` examples, for 2D and 3D representations.

Since the images you present looks like flowcharts, see the flowchart gallery.

-