Graphs and LaTeX

Discussion in 'Mac Programming' started by Cromulent, Apr 5, 2008.

  1. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #1
    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?
     
  2. macrumors regular

    Joined:
    Sep 12, 2006
    #2
    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).
     
  3. macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #3
    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.
     
  4. macrumors 6502

    Berlepsch

    Joined:
    Oct 22, 2007
    #4
    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.
     
  5. macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #5
    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.
     
  6. macrumors regular

    Joined:
    Jun 9, 2007
    #6
    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.
     
  7. macrumors 65816

    telecomm

    Joined:
    Nov 30, 2003
    Location:
    Rome
    #7
    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).
     
  8. macrumors member

    cruzrojas

    Joined:
    Mar 26, 2007
    Location:
    USA
    #8
  9. thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #9
    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.
     
  10. macrumors 6502a

  11. macrumors regular

    Joined:
    Jan 8, 2008
    #11
    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
     
  12. macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #12
    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?
     
  13. macrumors 65816

    telecomm

    Joined:
    Nov 30, 2003
    Location:
    Rome
    #13
    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...
     
  14. thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #14
    Discrete maths.
     
  15. macrumors newbie

    Joined:
    Dec 27, 2007
    #15
  16. macrumors 65816

    telecomm

    Joined:
    Nov 30, 2003
    Location:
    Rome
    #16
  17. macrumors 6502

    Joined:
    Jun 2, 2003
    #17
    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.
     
  18. macrumors 6502

    Monkaaay

    Joined:
    Jun 19, 2006
    Location:
    Richmond, VA
    #18
    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.
     
  19. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #19
    That sounds like the most sensible thing to do. You can use \caption for a caption too.
     
  20. thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #20
    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.
     
  21. macrumors newbie

    Joined:
    Dec 27, 2007
    #21
    No, I mean any sort of graph. 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.
     
  22. macrumors 65816

    telecomm

    Joined:
    Nov 30, 2003
    Location:
    Rome
    #22
    Oh, did the OP want graphs in the sense of "graph theory"? I always do these using the xy package.
     
  23. macrumors newbie

    Joined:
    Dec 27, 2007
    #23
    He said
    But he also said
    So who knows.
     
  24. thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #24
    Huh? Its perfectly legitimate to model population discretely or am missing the point of your post?
     
  25. macrumors G4

    Joined:
    Jul 17, 2002
    Location:
    USA
    #25
    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.
     

Share This Page