[R] creating axis of the plot before data are plotted

From: Zroutik Zroutik <zroutik_at_gmail.com>
Date: Mon, 14 Jul 2008 17:21:56 +0200


Dear R-users,

I'm tackling with a problem which causing me a head-ache for a long time. I would like to create a nice x-axis to my plots, but I do not know how to implement the method.

Imagine a matrix where you have rownames real numbers -- these rownames should be written in the x-axis nicely. I could not find any way how.

I'll describe what I'm doing now:
I have a matrix where each column is an independent curve (number of the columns 3-4). The rownames are the x-axis, and the names are real numbers (converted to chars, of course). I find the max and the min among the values in the matrix (for the y-axis) and I'm creating an empty plot. x-axis is c(0, nrow(matrix)). Now, I'm creating the x-axis labels

Labels <- seq(1, nrow(matrix), by = 100) axis(1, at = NULL, labels = rownames(matrix)[Labels])

At this point I'd like to have instead of "24.12333 26.45667 28.79 31.12333 33.45667" at the x-axis, an optimally placed ticks at let's say "26 28 30 32" -- this is what I cannot achieve.

Afterwards I'm plotting the curves in different colours. I know that the x-values are accessed by the number of their row and not rowname.

Anybody could point me into some direction, please? Thank you upfront!

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 14 Jul 2008 - 15:27:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Jul 2008 - 16:31:58 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive