[R] Placing axes label strings closer to the graph?

Ajay Narottam Shah ajayshah at mayin.org
Sat Oct 1 09:32:00 CEST 2005


Folks,

I have placed an example of a self-contained R program later in this
mail. It generates a file inflation.pdf. When I stare at the picture,
I see the "X label string" and "Y label string" sitting lonely and far
away from the axes. How can these distances be adjusted? I read ?par
and didn't find this directly.

I want to hang on to 2.8 x 2.8 inches as the overall size of graph,
but it will be nice if the inner square frame was bigger and thus the
axes were closer to the strings. I will be happy with (say)
par(mai=c(.6,.6,.2,.2)). But if I just do this, the "X label string"
and "Y label string" were lost.

Thanks,

        -ans.

D <- structure(list(dates = c(1983, 1984, 1985, 1986, 1987, 1988,
                      1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
                      1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
                      2005), inflation = c(7.6, 12.1, 6.3, 6.8, 8.7,
                               8.8, 9.4, 6.1, 11.6, 13.5, 9.6, 7.5, 10.1, 10.2,
                               9.3, 7, 13.1, 3.4, 3.7, 4.3, 4.1, 3.7, 4)),
               .Names = c("dates", "inflation"), row.names =
               c("1", "2", "3", "4", "5", "6", "7", "8", "9",
                 "10", "11", "12", "13", "14", "15", "16", "17",
                 "18", "19", "20", "21", "22", "23"), class =
               "data.frame")

pdf(file="inflation.pdf", width=2.8, height=2.8, bg="cadetblue1")
par(mai=c(0.8,0.8,0.2,0.2))
plot(D$dates, D$inflation, xlab="X label string", ylab="Y label string",
     type="l", lwd=2, col="cadetblue4", cex.axis=0.6, cex.lab=0.6)

-- 
Ajay Shah                                                   Consultant
ajayshah at mayin.org                      Department of Economic Affairs
http://www.mayin.org/ajayshah           Ministry of Finance, New Delhi




More information about the R-help mailing list