# Are there any packages for creating charts?

I'm looking for a package in which you can create nice bar and/or line charts in LaTeX. Currently I'm plotting the charts in Calc (OpenOffice), export it to a PDF document, crop it and then including it as graphics.

I reckon there should be some more efficient way of doing this, preferably entirely in LaTeX.

-

You can take a look at PGF/TikZ, then on top of that is pgfplots. To see it in action, see TeXample.net.

-
pgfplots certianly is a good choice when it comes to bar charts. also the mailing list is very active and there is constant development going on –  Martin H Jan 18 '11 at 14:12

with PSTricks you can have also 3D charts with hidden surfaces

-

To keep in line with previous answers, you can look at Metapost or Asymptote, though I guess it might be easier to use a combination of R and Sweave for that particular purpose, especially if you want to load your data from an external file (but see related questions tagged sweave).

-
+1 for Sweave. If you are independently using R for your statistics, then it makes sense to be using it for charts in your documents. There's also the great TikZDevice package for R. (r-forge.r-project.org/R/?group_id=440) –  Alan Munn Jan 18 '11 at 16:08

I can't seem to be able to correctly format multiline code in a comment, thus I'm adding another answer voting for PGF/TikZ, it's great!

Here's an (slightly adapted :) example of a plot I recently made with pgfplots.

\documentclass{article}
\usepackage{pgfplots}
\usepackage[pdftex,active,tightpage]{preview}
\begin{document}
\begin{preview}
\begin{tikzpicture}
\begin{axis}[
ylabel={Some Label [\%]},
ybar,
bar width=62pt,
xtick=data,
xticklabel={Something},
legend style={at={(0.05,0.62)},anchor=north west}
]
\legend{First Thing,Second Thing}
\end{axis}
\end{tikzpicture}
\end{preview}
\end{document}

-
it is giving me this error - ! Undefined control sequence. \pr@ship@end ...n@ii =\dimen@ \global \pdfvorigin \dimen@ \dimen@ \dp \pr@bo... l.20 \end{preview} not sure what am i doing wrong –  Aku Jan 20 '11 at 15:47
It does run for me with pdfLaTeX, both on Windows and Mac... You can maybe try to remove the \usepackage[pdftex,active,tightpage]{preview} as well as both the \begin{preview} and \end{preview} as this only produces a cropped pdf... –  Habi Jan 24 '11 at 16:53

I would use pgf/TikZ too, just like other users who answered.

There are some really old packages bar, barkom. An newer one, worth a try, is bardiag, based on PSTricks.

A PSTricks package for this purpose is pst-bar.

-