Zroutik Zroutik
2008-Jul-14 15:21 UTC
[R] creating axis of the plot before data are plotted
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]]
stephen sefick
2008-Jul-14 15:53 UTC
[R] creating axis of the plot before data are plotted
try at=seq(from=26, to=32, by=2) in the axis statment hope this helps Stephen On Mon, Jul 14, 2008 at 11:21 AM, Zroutik Zroutik <zroutik@gmail.com> wrote:> 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@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. >-- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]]