P.Mean: Drawing simple mathematical graphs (created 2009-01-14). |

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

www.childrens-mercy.org/stats/weblog2007/CyclicalTrends.asp

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.

`par(mar=rep(0.1,4))`

plot(0:100,0:100,type="n",axes=FALSE,xlab=" ",ylab=" ")

text(90,80,"Positively\nBiased\nControl\nGroup")

text(20,80,"Negatively\nBiased\nControl\nGroup")

text(50,80,"Ideal\n(Zero Bias)\nControl\nGroup")

arrows(90,55,90,10,length=0.05)

arrows(20,55,20,10,length=0.05)

arrows(45,55,30,10,length=0.05,lty="dotted")

arrows(50,55,60,10,length=0.05,lty="dotted")

arrows(55,55,80,10,length=0.05,lty="dotted")

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.

This work is licensed under a Creative Commons Attribution 3.0 United States License. This page was written by Steve Simon and was last modified on 2010-04-12. Need more information? I have a page with general help resources. You can also browse for pages similar to this one at Category: Graphical display.