PDA

View Full Version : Graphs and LaTeX




Cromulent
Apr 5, 2008, 12:33 PM
This is probably the wrong forum but the people who read this one are the ones who are most likely to know the answer to this question.

I'm doing a little maths report for my own enjoyment and would like to include a few graphs. Now I have read some tutorials for including graphs using LaTeX but they seem to just be including an EPS file. Are there any pieces of software that you could recommend that can produce nice looking graphs that can save in EPS format so that I can include them in maths report?



Kendall015
Apr 5, 2008, 12:50 PM
I don't have a specific answer to your question, but I personally have found LaTeX to be more trouble than it's worth. As a student, I usually have strict requirements in terms of formatting, and it has been a pain to make LaTeX documents that follow these requirements. If you're writing a thesis then it may make sense to use LaTeX, or if you include a lot of mathematical equations, but for use as an alternative for writing papers I don't think it's worth the trouble, especially with so many quality WYSIWYG alternatives like Pages, Word '08 (which is actually much improved), Mellel, and NeoOffice (which is decent).

yeroen
Apr 5, 2008, 01:36 PM
I know Graphviz outputs to Postscript, but the output from the LaTex packages (like tkz-berge.sty) look better, in my opinion.

What LaTex graph package are you using now? In my thesis, I used LaTeX to draw the (complicated, 3D) commutative diagrams from homological algebra. That was 11 years ago. Apart from some trial and error it wasn't too difficult IIRC, and the situation has almost surely improved immeasurably since then.

If you haven't done so already, check out the LaTeX Graphics Companion (http://www.amazon.co.uk/LATEX-Graphics-Companion-Illustrating-Typesetting/dp/0321508920/ref=sr_1_1?ie=UTF8&s=books&qid=1207420753&sr=8-1).

Berlepsch
Apr 5, 2008, 03:13 PM
Crom,

you should have a look at pdflatex, which, I believe, is part of any standard latex installation nowadays. It creates PDF files directly from *.tex, and included graphics can be in PDF format, which is of course very handy on the Mac. Just have a look at the documentation, in combination with the pdftex package it's quite a powerful tool.

yeroen
Apr 5, 2008, 03:21 PM
Crom,

you should have a look at pdflatex, which, I believe, is part of any standard latex installation nowadays. It creates PDF files directly from *.tex, and included graphics can be in PDF format, which is of course very handy on the Mac. Just have a look at the documentation, in combination with the pdftex package it's quite a powerful tool.

I believe he's looking for something to visually construct the graphs in (rather marking them up in LaTeX) and then import that into his LaTex files.

chem
Apr 5, 2008, 03:45 PM
I'm doing a little maths report for my own enjoyment and would like to include a few graphs. Now I have read some tutorials for including graphs using LaTeX but they seem to just be including an EPS file. Are there any pieces of software that you could recommend that can produce nice looking graphs that can save in EPS format so that I can include them in maths report?

Yes. The exact program you want is called xmgrace. It's a 2D graphing program for X11/GNU Linux that runs fine under OS X. I link to it and discuss its installation under macports at this blog entry: http://yocto.wordpress.com/2008/02/27/personal-installation-of-os-x-1052/

I also discuss installation of TeXLive and PyX, another graphing program that uses LaTeX markup.

telecomm
Apr 5, 2008, 04:15 PM
Hmmm... is there any reason you can't use, say, Pages or Excel to produce your graph? Why not use one of these programs (or whatever you like), then save an image of the graph, say, a jpg.

use the graphicx package (part of the usual default installation), and then use something like...
\begin{figure}[h]\begin{center}
\includegraphics[scale=0.whatever]{filename.ext}
\end{center}\end{figure}

Edit: The easiest thing to do might be to create your graph in whichever program you like, then save it as a PDF (one of the file types you could then use with the \includegraphics command).

cruzrojas
Apr 5, 2008, 04:57 PM
You could also gnuplot which in my opinion is really easy to use.
www.gnuplot.info

Take a look at my blog for some info on how to use gnuplot and latex together.
http://chuyandmac.blogspot.com/2007/05/tutorial-make-latex-ready-plots-using.html

If you have any trouble let me know and I might be able to help.

Sometimes getting Latex to work right is problematic, but I think at the end is worth the effort.

Cromulent
Apr 5, 2008, 05:04 PM
Thanks for the help guys, some good information. I'll take a look at the suggestions. I'm not sure I need the power that some of these packages offer though, graphviz looks very good but it does seem to be a bit overkill for making graphs modelling population growth.

AlmostThere
Apr 5, 2008, 06:08 PM
Wikipedia roundup...

http://en.wikipedia.org/wiki/List_of_graphing_software#Plotting_programs_.28graphing_programs.29

phjo
Apr 5, 2008, 11:14 PM
The tricky part about graph inclusion in latex is that there are two tex/latex engines in a standard distribution. The first one does

.tex->.dvi and additional tools transform the .dvi into .ps or .pdf (with Texshop : this is the TeX+Ghostscript route,

or directly

.tex->.pdf with pdfTeX.

It is quite simple to include graphs with either of them BUT :
- with the first engine : you will only be able to include postscript files
- with the second : you can include .png, .jpg, .pdf (and maybe others) but not postscript...

all this with the same commands such as

\includegraphics[width=8cm]{myGraph.(png,jpg,pdf)}

Now, for simple things, you might want to use the tex/latex engine to draw itself a graph instead of importing one, but you probably don't want to do it by hand (you could get the better output doing that, such as mixing graph and formulas or variable with the same fonts than the rest, but again, for simple things) : the packages epic, eepic from latex allows one to do that.

I suggest to have a look at jPicEdt for that (java multiplatform)

Of course, the venerable xfig, running over x11 could be of some use as well. I remember outputing graphs with Maple as postscript without legends, and adding those with xfig using some mixed eps+tex(epic) mode...

As for graphs of curves and whatever, why not Apple's Grapher ? It can do pdf and eps...

phjo

yeroen
Apr 6, 2008, 04:30 AM
Do you mean graphs as in 'the graph of a function y=f(x)' or are you talking about graphs in the sense of discrete mathematics?

telecomm
Apr 6, 2008, 04:34 AM
Do you mean graphs as in 'the graph of a function y=f(x)' or are you talking about graphs in the sense of discrete mathematics?

If it's the former, I'd also suggest Grapher (in the Utilities folder), though it'd be nice if they worked some of the bugs out...

Cromulent
Apr 6, 2008, 04:46 AM
Do you mean graphs as in 'the graph of a function y=f(x)' or are you talking about graphs in the sense of discrete mathematics?

Discrete maths.

eharley
Apr 6, 2008, 09:02 AM
http://www.omnigroup.com/applications/OmniGraffle/

telecomm
Apr 6, 2008, 09:08 AM
http://www.omnigroup.com/applications/OmniGraffle/

...only if by 'graph' the OP meant 'flowchart' :D

pooky
Apr 6, 2008, 10:11 AM
R is mostly a statistical program, but also produces pretty decent graphics. Not sure if it does .eps natively, but there is probably an extension somewhere. It will natively output to pdf and postscript.

Monkaaay
Apr 6, 2008, 10:29 AM
I'm not sure about the eps format, but recently I've been using the open source library from Google to make graphs. I would suggest giving it a look to see if it would work in your situation.

Eraserhead
Apr 6, 2008, 10:33 AM
Hmmm... is there any reason you can't use, say, Pages or Excel to produce your graph? Why not use one of these programs (or whatever you like), then save an image of the graph, say, a jpg.

use the graphicx package (part of the usual default installation), and then use something like...
\begin{figure}[h]\begin{center}
\includegraphics[scale=0.whatever]{filename.ext}
\end{center}\end{figure}

Edit: The easiest thing to do might be to create your graph in whichever program you like, then save it as a PDF (one of the file types you could then use with the \includegraphics command).

That sounds like the most sensible thing to do. You can use \caption for a caption too.

Cromulent
Apr 6, 2008, 10:42 AM
That sounds like the most sensible thing to do. You can use \caption for a caption too.

That solution is a good one except for a few reasons:

I don't have Excel
Numbers or Pages do not have the required graphing capabilities
Images do not scale where as postscript files do


Good to know that I can include images so easily though.

eharley
Apr 6, 2008, 11:23 AM
...only if by 'graph' the OP meant 'flowchart' :D

No, I mean any sort of graph (http://en.wikipedia.org/wiki/Graph_%28mathematics%29). OmniGraffle makes it super easy to draw vertices, connect them with edges (directed or undirected), and manipulate the layout of the vertices while still maintaining connectivity (ie. you don't have to go back in and redraw the edges).

It exports fantastic PDFs which are dead simple to import into LaTeX documents using pdftex the graphicsx package.

Graphviz is great but it's a pain in the butt to manipulate the location of your vertices. OmniGraffle includes the automatic layout routines that Graphviz includes, plus OmniGraffle can import DOT files.

telecomm
Apr 6, 2008, 11:50 AM
No, I mean any sort of graph (http://en.wikipedia.org/wiki/Graph_%28mathematics%29).

Oh, did the OP want graphs in the sense of "graph theory"? I always do these using the xy package.

eharley
Apr 6, 2008, 12:29 PM
Oh, did the OP want graphs in the sense of "graph theory"? I always do these using the xy package.

He said
Discrete maths.

But he also said
Thanks for the help guys, some good information. I'll take a look at the suggestions. I'm not sure I need the power that some of these packages offer though, graphviz looks very good but it does seem to be a bit overkill for making graphs modelling population growth.

So who knows.

Cromulent
Apr 6, 2008, 12:45 PM
So who knows.

Huh? Its perfectly legitimate to model population discretely or am missing the point of your post?

MisterMe
Apr 6, 2008, 01:39 PM
...

I'm doing a little maths report for my own enjoyment and would like to include a few graphs. Now I have read some tutorials for including graphs using LaTeX but they seem to just be including an EPS file. Are there any pieces of software that you could recommend that can produce nice looking graphs that can save in EPS format so that I can include them in maths report?I am not sure that you want to do this on a lark. To do everything with expected level of quality, you will have to spend some money. First, you will need a quality charting application. I love KaleidaGraph. I can also recommend DeltaGraph. It is actually difficult to make a graph in Igor Pro that is less than textbook quality. Grapher can save to PDF and EPSF. However, the graph and not the graphics format is the thing. By this standard, Grapher is not only not in the same league, it does not play the same game.

Print directly to PDF from any of your graphing applications. Or print to PostScript and use Adobe Distiller to generate your PDF. Alternatively, you can convert your PostScript file to EPSF. PDF seems to have largely eclipsed EPSF as the preferred high-quality vector graphics format on the Mac. I believe that Adobe Illustrator is the last commercial graphics editor to support EPSF.