Drawing simple mathematical graphs (created 2009-01-14)

This page is moving to a new website.

I'm looking for a good, basic, relatively easy-to-use graphing program, to draw simple mathematical graphs one would see in basic calculus, algebra, statistics. Something similar to Paint, but a step or two up from it, and that I could copy and paste images, venn diagrams, etc., into a Word file, and the quality would be publication quality. I want something that is MUCH more versatile than one would get using Excel or similar.

This was a recent inquiry on EDSTAT-L (DD) and it drew several responses. Here's what I wrote:

If you're on edstat-l, there's a good chance that you are using a statistical package like SAS or R. Most stat packages allow you to place lines, curves, text, etc. on a graph pretty much anywhere you want. The interface is sometimes crude, but you already know the system. I show a few different sine curves, for example, at


and these graphs were all done in R. There are a few tricks, such as drawing a graph with no data points (type="n" in the plot function) suppressing the axes (axes=FALSE in the plot function) and setting the margins around the graph to 0 (mar=rep(0,4) in the par function). Then I use a series of segment and text functions.

I don't have the code for the sine curves handy, but here is an example showing how using two control groups, one with a positive bias and one with a negative bias, can place a bound on the true (unbiased) result.

plot(0:100,0:100,type="n",axes=FALSE,xlab=" ",ylab=" ")
text(50,80,"Ideal\n(Zero Bias)\nControl\nGroup")
text(30, 5,"?")
text(60, 5,"?")
text(80, 5,"?")

The problem with R is there's some trial and error involved (should the arrow start at 90,55 or at 95,55?). But you figure out things pretty quickly. If I was really smart, I'd use the locator function, but I haven't done this yet.

It's been a decade since I've used SAS, but they have an annotate function for graphs that works well. SPSS doesn't have good enough tools for this sort of thing. I haven't worked enough with Stata or any other package to say whether they could produce these types of graphs.

There are probably better drawing programs around, but you already have SAS or R, so the price is right, and the learning curve is not too steep because it is just learning some new features of a program you already know rather than learning an entire system.

By the way, since we're talking about graphs, I did one animated graph that I am quite proud of. It is a sequence of 100 R graphs linked together by GIF Animator and shows how the Metropolis algorithm works.