From: Zroutik Zroutik <zroutik_at_gmail.com>

Date: Tue, 15 Jul 2008 15:00:26 +0200

....

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 Tue 15 Jul 2008 - 13:03:24 GMT

Date: Tue, 15 Jul 2008 15:00:26 +0200

Solved. I tried to create a minimal example, but my script is too
complicated to just cut out lines (too many dependencies). Instead of
it, I sketch

my idea. I do not say it is the nicest solution, but it works as I wanted.

The first five rows of my data-matrix:

> data_svd$u[1:5,]

[,1] [,2] [,3] [,4] [,5] [,6] [,7] 25.12333 -0.05845695 0.01147999 0.01369034 -0.014098243 -0.01332110 -0.03411848 -0.069044764 25.14667 -0.06067676 0.01207400 0.01567369 -0.003540611 -0.01833136 -0.04716164 -0.037310769 25.17 -0.06218749 0.01247501 0.02173719 0.008295593 -0.02289422 -0.03785958 -0.005219312 25.19333 -0.06310108 0.01122596 0.02510501 0.015560052 -0.01741544 -0.03004161 0.008608083 25.21667 -0.06362390 0.01073240 0.02882440 0.021066152 -0.02108871-0.02228662 0.012336997

....

The rowname is printed as first at the beginning of the line. Now, I define
the X-axis range:

*> XTimeRange <- seq(from=as.numeric(rownames(data_svd$u)[1]),
*

to=as.numeric(rownames(data_svd$u)[nrow(data_svd$u)]),
length=nrow(data_svd$u))

and plot the empty plot:

*> Components <- seq(1:4) # first four columns from the data-matrix
**> plot(c(XTimeRange[1], XTimeRange[length(XTimeRange)]),
*

c(min(data_svd$u[,Components]), max(data_svd$u[,Components])), type = "n",
main="Plot of the \"base\"", xlab = "time / ps", ylab = "a.u.")

the x-axis is created automatically and nicely :) Now, I plot the curves
into the plot with the same x-axis range:

*> for (x in rev(Components)) points(data_svd$u[, x]~XTimeRange, col = x,
*

type = "l")

My problem was in understanding what has to be assigned to the x-axis and
when:

*> plot(c(XTimeRange[1], XTimeRange[length(XTimeRange)]),....
**> points(data_svd$u[, x]~XTimeRange,...
*

(Right now, I do not think it was so hard to create it, but anybody interested in running the script I can support the script.)

Thank you very much for all hints

It was a tough night... and in the morning I loved R a bit more. Zroutik

On Tue, Jul 15, 2008 at 12:18 AM, stephen sefick <ssefick_at_gmail.com> wrote:

> why don't you give us a snippett of your data and then we may be able to

*> help (read the posting guide)
**>
**>
**> On Mon, Jul 14, 2008 at 6:04 PM, Zroutik Zroutik <zroutik_at_gmail.com>
**> wrote:
**>
**>> Nope, this assigns the 26th, 28th, 30th anf 32nd point of the total
**>> nrow(matrix) number of points. This does not assign the points (or places of
**>> the x-axis) with such a rowname.
**>>
**>> row number <-> row name
**>> 1:nrow(matrix) <-> rowname(matrix[1]) .. rowname(matrix[nrow(matrix)])
**>>
**>>
**>> I try to rephrase my question: how do you plot a curve into a plot when
**>> the x-axis isn't the rownumbers, but each row is a real x-value (e.g.
**>> 35.23)?
**>>
**>>
**>> p.s. there is a mistake in my original (first) email. Instead "at=NULL"
**>> should be "at=Labels" (otherwise there is an error message). Sorry for
**>> confusion.
**>>
**>>
**>> On Mon, Jul 14, 2008 at 5:53 PM, stephen sefick <ssefick_at_gmail.com>
**>> wrote:
**>>
**>>> 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_at_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_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.
**>>>>
**>>>
**>>>
**>>>
**>>> --
**>>> 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
**>>
**>>
**>>
**>
**>
**> --
**> 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]]

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 Tue 15 Jul 2008 - 13:03:24 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 Tue 15 Jul 2008 - 13:31:44 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.
*