Graphics, Figures & TablesBest Practice for Graphs

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
pottertl
Posts: 7
Joined: Wed Jan 05, 2011 10:33 pm

Best Practice for Graphs

Post by pottertl »

I'm preparing a document for which I need to make a variety of 2D graphs, generally plotting simple functions such as sin(x), sqrt(x), etc. I need to be able to label the graphs, choose the axes variables, and have multiple functions on one graph, but that's about all I need.

Given my needs, what is simplest way to do this? I'm using Mac OS X if that is important. Is there a good "graphing" program I should download to create the graphs, and then export them to PDF or PNG?

The simpler the better, provided I can accomplish the goals listed above. Any thoughts are welcome.

Thanks in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Knuffi
Posts: 25
Joined: Fri Oct 10, 2008 1:27 pm

Best Practice for Graphs

Post by Knuffi »

Hm, it's not LaTeX specific, but I would recommend GeoGebra. It's a Java based program originally for geometry, but it can handle simple graphs as well and you have full control about the axes and can label everything. Export to PNG or JPG.
torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Re: Best Practice for Graphs

Post by torbjorn t. »

Geogebra can also export as TikZ or PSTricks code that you can include in your document. It does a pretty good job with TikZ at least, though some you might want to make some adjustments to the code.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Best Practice for Graphs

Post by localghost »

Try pgfplots (based on PGF/TikZ) or pst-plot (based on PSTricks). It will give you full control over your graphs from inside your LaTeX code. No export necessary.

A short example with pgfplots. The output is attached.

Code: Select all

\documentclass[11pt]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}

\pgfplotsset{
  compat=newest,
  xlabel near ticks,
  ylabel near ticks
}

\begin{document}
  \begin{tikzpicture}
    \begin{axis}[
      xlabel={$x$ / rad},
      ylabel={$\sin(x)$},
      samples=100
    ]
      \addplot[blue,smooth] {sin(deg(x))};
      \addlegendentry{Sine curve};
    \end{axis}
  \end{tikzpicture}
\end{document}

Thorsten
Attachments
qtmp.png
qtmp.png (4.97 KiB) Viewed 4148 times
Post Reply