TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have set up the TexLive distribution on my Ubuntu system. What graphics or graph-drawing package should I use to embed bar graphs in my LaTeX documents?

share|improve this question
up vote 11 down vote accepted

I find that if I am creating a plot or graph, I often need some data munging/analysis capabilities which are decidedly outside the scope of "stuff TeX was designed to be good at".

Therefore, I use programming languages other than TeX which are suited to creating plots and have support for exporting the plots to a LaTeX-friendly format such as TikZ code. Some such languages are:

Full disclosure: I am a co-author of the tikzDevice for R

Also worth mentioning is Python's matplotlib which does not render to TikZ code, but has support for letting TeX handle the typesetting of plot text.

gnuplot is another program that is worth consideration. TikZ already has some functionality for calling out to gnplot to generate graphs. See section 18.6 "Plotting a Function Using Gnuplot" in the TikZ Manual for more details. Another interesting development is that the gnuplot folks are working on a Lua-based terminal that should provide stronger ties to TikZ and LuaTeX.

If you have a simple plot and want a LaTeX-only solution, the pgfplots package mentioned by Martin is probably a good way to go. However, you may find yourself wishing for a more powerful system once things get complex and data needs to be filtered/transformed before plotting. Hopefully the brave new world of LuaTeX will help solve these problems- but I feel that Lua has a ways to go before it approaches the data analysis and visualization capability of a language like R that was developed for these tasks.

share|improve this answer
+1 for using data analysis tools. Instead of tikzDevice, you could also output the bar graph in R as pdf and use \includegraphics in LaTeX then. R supports this route with its Sweave function. – Karsten W. Aug 8 '10 at 22:53
The only difference in usage between the PDF device and tikzDevice is that you use \input{plot.tex} instead of \includegraphics{plot.pdf} (of course, the file type suffixes should be left off). The advantage of the tikzDevice when compared to PDF is that LaTeX handles all of the text typesetting- so there are no discontinuities between the text of your paper and the text in the graphics. – Sharpie Aug 8 '10 at 23:21
Actually there is a matplotlib2tikz script. – pmav99 May 17 '11 at 10:26
@pmav99: the link is broken. Thanks so much for mentioning it, though. I am switching from Matlab to Python and I was worried I wouldn't find anything like matlab2tikz to give me tikz code easily :) – Vivi Jun 22 '11 at 4:31
@Vivi github.com/nschloe/matplotlib2tikz – pmav99 Jun 22 '11 at 7:12

I would recommend the pgfplots package. It is based on the earlier mentioned tikz package and produces nice plots. The documentation is full of examples you can often just copy&paste and add your data.

share|improve this answer

For complex math, sagemath has the best LaTeX support of the mathematics programs I have used. They make a LaTeX package for including math code directly in your LaTeX script and incorporate the plots wonderfully.

I should note, however, that sagemath's bar graph is pretty wimpy at the moment. Fortunately, if you know just a touch of python, you can easily make your own by combining plots of lines from the axis to the measured value.

There are also some math tools (such as qtiplot) that will export plots in TikZ format.

share|improve this answer

If you already have the bar charts drawn with something like mathematica, maple or the like, export them as eps or pdf (depending on whether you are using latex or pdflatex) and then use the \includegraphics command to include them.

Or if you want to draw them inside LaTeX, TikZ is powerful. Or if you want to draw graphs in LaTeX using statistical data you might want to look at Sweave (but this is probably overkill...)

share|improve this answer

I found octave the most convenient tool (quick and easy to learn the required syntax) for creating various charts, being not familiar with more advanced statistics software, but having used MATLAB in school.

share|improve this answer
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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