Documents Automation - Charts and Graphs

Overview

Often times a document needs to include a chart, graphs or other images. There are essentially two ways this can be accomplished.

The first is to include a image file in the document, the second is to use the pgf-plots package to generate a chart.

Including a Chart Image

One way to inlcude a chart is to generate the chart first as an image file, such as a png or jpg. Then to include the image in the latex as follows.

\begin{figure} \includegraphics[width=\linewidth]{chart.jpg} \caption{A Chart} \label{fig:chart} \end{figure}


Pgf-Plots

The Pgf-Plots library is used to generate a chart that is rendered within the document. Pgf Plots uses the tikz package, which should be included at the top of the document.

(see tikz)

\usepackage{tikz}


The following is a sample pgf-plot.

\begin{tikzpicture} \begin{axis}[ width=1.0\textwidth, height=1.0\textwidth, title=pgf plotline, xlabel={}, ylabel={}, ] \addplot[color2] coordinates{ (1,94.51442087133495) (2,96.84622195737506) (3,91.45426479244023) (4,87.20952507119303) (5,83.64989756719986) (6,85.41100775079231) (7,95.28746812683444) (8,89.52511592590162) (9,101.59770968801081) (10,105.70768295524825) (11,101.70109196498785) (12,106.22071425573245) }; \end{axis} \end{tikzpicture}


For information about automatically generating a chart from data in the latex app, see generating a chart