We are creating an easy-to-use LaTeX template for our institution. I'd like to have a pure LaTeX way to create simple bar graphs and pie charts. Does anything exist? I can certainly throw the students at matplotlib or gnuplot, but it would be nice to have something simpler.

  • Well, there is TikZ/PGF which is a pure LaTeX way to create basically any form of diagram. However, LaTeX beginners would benefit from a macro wrapper where they just can feed there values and styles in. No idea if such a macro for bar and pie charts already exists. – Martin Scharrer Oct 10 '11 at 19:08
  • I wouldn't say TikZ/PGF is simpler than matplotlib. However, it produced much nicer results. With matplotlib, I always have issues when I want larger fonts; I usually reduce the figure-size while keeping font-sizes, but then labels fall outside the figure. Calculating bounding-boxes is one of the strengths of LaTeX, so I would recommend pgfplots, not because it's simpler, but because it produces nicer results, particularly when larger fonts are needed (like in presentations). – gerrit Dec 9 '11 at 9:31

The usual answer here is the pgfplots package, which is based on TikZ. Note that it does not do pie charts, as these are considered misleading by many people. (There is some discussion of this issue in the TikZ manual.)

(Note: As mathematicians use 'graphs' for something entirely different, the usual way to refer to data display in a graphical form is as a 'plot'. You'll find a number of plot-related questions on the site.)

  • Thanks. I also do not like pie charts (see perceptualedge.com/articles/08-21-07.pdf), but people demand them. Thanks for the pointer to pgfplots. I was not aware of it. It's pretty amazing. – vy32 Oct 10 '11 at 19:53
  • 2
    Re: Pie charts; I think that the "misleading"-part in the pgfmanual was in relation to "3d" piecharts, not "flat" piecharts. – morbusg Oct 11 '11 at 3:54
  • What is a good alternative to a pie chart, which can represent this kind of data, such as percentages? – Village Dec 9 '11 at 2:07
  • 2
    @Village The problem with pie charts is actually comparing the sizes is hard, so people tend to put the numbers on. At that point, a table is a better choice. – Joseph Wright Dec 9 '11 at 6:51
  • 2
    @Village: found it: perceptualedge.com/articles/08-21-07.pdf – morbusg Feb 2 '12 at 8:51

Pure (La)TeX charts are possible in a variety of ways. Most notable are the options offered by TikZ/PGF and PStricks. See the respective documentations for ample examples on the functionality and use.

Although PStricks is predominantly Postscript orientated, it can be used in PDF environments as well by using the auto-pst-pdf wrapper.

Using PStricks, the pst-bar package provides an interface for bar charts. View the PStricks bar chart gallery for more on the possibilities. The PStricks pie chart gallery also has some neat examples of pie charts. PStricks also has pst-plot from plotting charts from external files (or not). pst-2dplot provides an interface for a variety of 2D plots (see the 2D gallery page), while pst-3dplot does the same for surfaces and other 3D charts (see the 3D gallery page).


An answer depends, in part, on what you mean by "pure" LaTeX. MetaPost, as this page mentions, is included in the TeXLive distribution and there is extensive documentation on Piecharts in MetaPost that can be downloaded here. Likewise, there is a Python package for Latex here so you can run LaTeX, jump into Python, create your graphs and jump back. There is a sagetex package as well (for Sage) and one for gnuplot. With respect to PSTricks, check the pstricks-add package for nice piecharts and the pst-func for barcharts. Note that a previous post has pst-bar as well.


And do not forget about datatool bundle! Its user interface is not the easiest to use (and it is also quite verbose), but you can wrap it into a few macros of your own and then it might be very useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.