[R] x axis point labels

Mark Myatt mark at myatt.demon.co.uk
Tue Sep 25 11:18:11 CEST 2001


Michaell Taylor <michaell.taylor at reis.com> writes:
>
>I am attempting to manually specify x axis value labels (NOT x axis label as 
>in xlab) on a density plot.  Generally speaking, I would like to erase the 
>default x axis point labels and replace them with arbitrary x axis point 
>labels relating to specific CDF points.
>
>I am sure this can be done, but it isn't obvious to me how.  Has anyone done 
>this before?

Just wrestled with something like this myself and this is the way I did
it:

        1. Set the lab parameter to the number of tickmarks you want on
        the x and y axes. If you have a vector of labels called (e.g.)
        my.labels then use something like:

                par(lab = c(length(my.labels, 5, 7))

        2. Plot without axes (i.e. add the parmeater "axes = false" to
        the plotting function you use top create your chart).

        3. Add axes using the axis() function:

                axis(side = 1, labels = mylabels)
                axis(side = 2)

Here is an example using a time series ... you should get the idea:

        Months <- c("May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
                    "Dec", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
                    "Jul")
        WheatI <- c(0.00, 0.97, 0.97, 0.87, 0.74, 0.64, 0.51, 0.28, 
                    0.26, 0.18, 0.00, 0.00, 0.00, 0.00, 0.00)

        par(lab = c(length(Months), 3, 7))     
        plot(WheatI * 100, type = "s", ylim = c(0, 100), xlab = "",
             ylab = "%", main = "Irrigated Wheat", bty = "n",
             axes = FALSE)
        axis(side = 1, labels = Months)
        axis(side = 2)

I hope that helps.

Mark


--
Mark Myatt


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list