I'm trying to put together some diagrams in LaTeX.

My dilemma is as follows. I have a technical report that contains a lot of images from MATLAB. I need to be able to freehand / draw other plots (such as wavelet functions):

wavelet functions

So I have a couple of options:

  • Use PowerPoint for all diagrams (the authoring tool I'm most familiar with). The problem is everything looks out of place / mismatched with stuff coming from MATLAB + PowerPoint
  • Use MATLAB for everything. Generating diagrams that illustrate my points the way I would like to can be a bit tedious but it can be done.
  • Use SOME KIND OF LaTeX diagramming toolkit. I currently don't know anything about LaTeX diagramming, but I wouldn't mind exploring. It seems tedious. Are there any LaTeX diagramming toolkits that have a GUI?

As an experienced LaTeX user, what is your guide to generating professional math graphs that don't look out of place and don't take decades to complete?

  • 6
    I (and most here) would recommend using tikz and pgfplots for this sort of thing. It's very powerful and once you get the hang of it, it's quite easy to use. If you browse through the tags here on the site you'll find plenty of examples to learn from.
    – Alan Munn
    Nov 20, 2011 at 22:15
  • 4
    matlab2tikz, a script to generate TikZ/PGFplots files from Matlab figures may also be useful. Nov 20, 2011 at 22:18
  • 1
    Another option would be to use gnuplot. It has several output formats (called terminals) that can be used with LaTeX.
    – Marco
    Nov 20, 2011 at 22:26

3 Answers 3


For tasks like this you can do everything with coordinates. As mentioned in the comments of your question, the package to use is pgfplots. It's text based, but very easy to use. I think it's actually better than Matlab for getting the plot how you want quickly. For example, your first plot would be (updated, thanks Jake!)



    scale only axis,
\addplot[color=blue,thick] coordinates {
            (0, 0)
            (0, 1)
            (1, 1)
            (1, 0)
% The following command puts the line in on the axis.
\draw ({rel axis cs:0,0} |- {axis cs:0,0}) -- ({rel axis cs:1,0} |- {axis cs:0,0});


which gives you this:

Simple plot with coordinates

Now that may look like a lot of code, but most of it is reusable. The axes labels are obvious, and the ranges too. This should be pretty clear if you're used to plotting in matlab. The scale only axis is to make the size of the pgfplot axes 6cm rather than the entire plot with labels.

Things are added to the canvas with \addplot. In this case I put in coordinates directly; perfect for your sketches. You can put in a file instead though. If your file contains columns of data with labels at the top. For example, this code

    scale only axis,
    xlabel={$\tau$ ($\mu$s)},
    table[x=time,y=fidelity] {data.txt};

with a data file data.txt that looks like this (tab delimited and easy to produce with Matlab)

time    fidelity
0.00000000e+00  0.00000000e+00
2.16135894e-01  1.11612759e-04
7.52429193e-01  8.16588122e-04
1.29606053e+00  8.76288172e-04
1.84266188e+00  7.06435551e-04
2.40147636e+00  7.93280613e-04
2.95870895e+00  6.89534671e-04
3.50977092e+00  8.62614471e-04

produces this

enter image description here

The most notable benefits of this approach is that if you're doing lots of similar plots you need only alter a few lines of coordinates, and that the typeface matches in size and style with the rest of your document. Another benefit is that the size of the plot is very easy to control, which I always found difficult with Matlab. Finally, if something changes, like you decide to use a different colour or correct a label, then it's a quick edit, rather than regenerating a whole graphic by opening up an external package.

  • 1
    Yup, very nice! For drawing the line at y=0, I would suggest using \draw ({rel axis cs:0,0} |- {axis cs:0,0}) -- ({rel axis cs:1,0} |- {axis cs:0,0});, which will draw a line from the left edge of the plot to the right edge, regardless of the axis limits. The expression looks a bit intimidating at first, but it's not too complicated: rel axis cs:0,0 is the lower left corner of the plot, axis cs:0,0 is the origin of the data coordinate system, (A|-B) is the point at the intersection of a vertical line through A and a horizontal line through B.
    – Jake
    Nov 21, 2011 at 2:24
  • Yup, that's true! I totally forgot, so I'll update the plot. Thanks!
    – qubyte
    Nov 21, 2011 at 2:30

The preferred diagramming tools in TeX are TikZ, PSTricks and MetaPost, all of which are text based and have a high learning curve. If you are looking at a easy to use GUI tool, have a look at Ipe. This PracTeX article gives a nice summary of the features and usage of Ipe.


Why not use pst-plot? It is one of PSTricks packages that is designed specifically for plotting almost anything with minimal effort. Visit PSTricks galleries and look around for pst-plot examples.



For simplicity, compile it with xelatex. For faster compilation, use latex-dvips-ps2pdf sequence.

See the output here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .