Re: [R] plot xlim/ylim range of axis

2010-11-10 Thread Steffen Uhlig

Hi Ivan,

thanks for the hint. Now it works as expected.

Sincerely,
/steffen

Am 10.11.2010 10:10, schrieb Ivan Calandra:

Hi,

The xlim and ylim arguments should be given the extremes of the range,
not a range:
plot(x=NULL,
y=NULL,
xlim=c(1, 10), ## with c()
ylim=v(1e-9, 1e-3), ## with c()
log=y)

HTH,
Ivan

Le 11/10/2010 10:00, Steffen Uhlig a écrit :

Dear mailing list readers!

Using R and the plot function I stumbled over this little issue:

plot(x=NULL,
y=NULL,
xlim=range(1:10),
ylim=range(1e-9:1),
log=y)

produces an plot empty plot, where the y-axis is in the specified
range. Changing ylim to

ylim=range(1e-9:1e-3)

creates an y-axis in the range of 1e-12 to 1e-6. This appearance of
the y-axis is a bit unexpected for me. Could anyone point me to a FAQ
entry why this happens?

Thank you very much in advance!

Sincerely,
/steffen







--
Steffen Uhlig, PhD
Mechatronik und Sensortechnik
HTW des Saarlandes
Goebenstraße 40
66117 Saarbrücken

Tel.: +49 (0) 681 58 67 274

__
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.


[R] plot xlim/ylim range of axis

2010-11-10 Thread Steffen Uhlig

Dear mailing list readers!

Using R and the plot function I stumbled over this little issue:

plot(x=NULL,
 y=NULL,
 xlim=range(1:10),
 ylim=range(1e-9:1),
 log=y)

produces an plot empty plot, where the y-axis is in the specified range. 
Changing ylim to


ylim=range(1e-9:1e-3)

creates an y-axis in the range of 1e-12 to 1e-6. This appearance  of the 
y-axis is a bit unexpected for me. Could anyone point me to a FAQ entry 
why this happens?


Thank you very much in advance!

Sincerely,
/steffen


--
Steffen Uhlig, PhD
Mechatronik und Sensortechnik
HTW des Saarlandes
Goebenstraße 40
66117 Saarbrücken

Tel.: +49 (0) 681 58 67 274

__
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.


[R] Plot of a subset of a data.frame()

2010-07-26 Thread Steffen Uhlig

Hello,

my data.frame is sort of a collection of process values, i.e. huge 
run-chart. It consists of a time-stamp in the first column (date as 
string), factors in the following columns (used for subset-filtering), 
and some process-data columns.
Hereafter, two examples are listed, showing the problems that occour 
during print:


At first the example, that works fine:

~~
a = c(1:10) # create a vector of integers
b = rep(c(a,b),5)   # create a vector of chars, used
# as factor-levels  
d = rnorm(10)   # some random numbers
e = data.frame(a,b,d)   # connect to a data.frame

e.1 = subset(e, b==a)   # create two subsets
e.2 = subset(e, b==b)
plot(d~a, e.1, pch=3, col=2) # plot first data-subset
points(d~a, e.2, pch=4, col=3) # plot the 2nd one

~~
all looks fine in theses plots.


However, changing the content of vector a to a set of strings the 
following happens:


~~
a = c(a,b,c,d,e,f,g,h,i,j)
e = data.frame(a,b,d)   # re-build data.frame

e.1 = subset(e, b==a) # create two subsets
e.2 = subset(e, b==b)
plot(d~a, e.1, pch=3, col=2)
points(d~a, e.2, pch=4, col=3)
~~
The plot-command produces horizontal lines instead of dots. This seems 
to happen when the x-axis contains strings rather than numbers. is there 
a way out?


Best regards,
/Steffen
--
Steffen Uhlig, PhD
Mechatronik und Sensortechnik
HTW des Saarlandes
Goebenstraße 40
66117 Saarbrücken

Tel.: +49 (0) 681 58 67 274

__
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.


Re: [R] Plot of a subset of a data.frame()

2010-07-26 Thread Steffen Uhlig

Dear David, Petr, and Alain,

thank you very much for your fast responses. It's a typical 
handbook-not-read-error at my side. I will dig deeper into the 
plot-functions and the assignment of data. I was not aware of that the 
vector a is handled as a vector of factors with 10 levels. Thanks for 
your suggestions and hints!


Best regards,
/steffen


Am 26.07.2010 14:30, schrieb David Winsemius:


On Jul 26, 2010, at 7:38 AM, Steffen Uhlig wrote:


Hello,

my data.frame is sort of a collection of process values, i.e. huge
run-chart. It consists of a time-stamp in the first column (date as
string), factors in the following columns (used for subset-filtering),
and some process-data columns.
Hereafter, two examples are listed, showing the problems that occour
during print:

At first the example, that works fine:

~~
a = c(1:10) # create a vector of integers
b = rep(c(a,b),5) # create a vector of chars, used
# as factor-levels
d = rnorm(10) # some random numbers
e = data.frame(a,b,d) # connect to a data.frame


You've gotten several answers, but none have addressed an aspect of R
behavior that took me longer to appreciate than it perhaps should have.
The b column inside the e data.frame is now a factor column. I
mention that because you later referred to it as a string which it is
not. It is an integer with an associated indexed level character vector.
Many of the functions that you might think would work on strings
will give either errors or unexpected results when applied to factors.




e.1 = subset(e, b==a) # create two subsets
e.2 = subset(e, b==b)
plot(d~a, e.1, pch=3, col=2) # plot first data-subset
points(d~a, e.2, pch=4, col=3) # plot the 2nd one

~~
all looks fine in theses plots.


However, changing the content of vector a to a set of strings the
following happens:

~~
a = c(a,b,c,d,e,f,g,h,i,j)
e = data.frame(a,b,d) # re-build data.frame

e.1 = subset(e, b==a) # create two subsets
e.2 = subset(e, b==b)
plot(d~a, e.1, pch=3, col=2)
points(d~a, e.2, pch=4, col=3)
~~
The plot-command produces horizontal lines instead of dots. This seems
to happen when the x-axis contains strings rather than numbers. is
there a way out?

Best regards,
/Steffen



--
Steffen Uhlig, PhD
Mechatronik und Sensortechnik
HTW des Saarlandes
Goebenstraße 40
66117 Saarbrücken

Tel.: +49 (0) 681 58 67 274

__
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.


[R] Handling of par() with variables

2010-06-04 Thread Steffen Uhlig
Hello!

In order to plot multiple graphs with the same set-up I use the
following code-structure:

###
# storing old parameter set
oldpar - par(no.readonly=T)

#copying old parameter set
newpar - par(no.readonly=T)

#adjusting parameters
newpar - par(mar=c(3.1,3.1,0.1,0.1),  # margin for figure area
  oma=c(0,0,0,0),  # margin for outer figure area
  cex.axis=0.9,  # axeneinteilung
  mgp=c(2,0.6,0),  # abstand der
achsenbeschriftung
  tck=0.02# major ticks innen
  )

...
...
postscript(...)
par(newpar)
...
dev.off()
###

Calling the variable newpar delivers the old paramter set only (from
code-line newpar - par(no.readonly=T)). If the code-segment newpar
- par(mar=... runs a second time, the correct paramter set is
stored, however, just the 5 parameters adjusted and not the full list.

My question is, why must the code segment newpar-par(mar...) run
twice? Is there a better way to handle the graphics output? I would be
grateful for a pointer on a FAQ-section or to an older discussion
thread in this group!

Thank you very much in advance!

Regards,
/steffen

__
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.


[R] Handling of par() with variables

2010-06-04 Thread Steffen Uhlig

Hello!

In order to plot multiple graphs with the same setup I use the
following code-structure:

###
# storing old parameter set
oldpar - par(no.readonly=T)

#copying old parameter set
newpar - par(no.readonly=T)

#adjusting parameters
newpar - par(mar=c(3.1,3.1,0.1,0.1),  # margin for figure area
 oma=c(0,0,0,0),  # margin for outer figure area
 cex.axis=0.9,  # font size axis
 mgp=c(2,0.6,0),  # distance of axis
 tck=0.02# major ticks inside
 )

...
...
postscript(...)
par(newpar)
...
dev.off()
###

Calling the variable newpar delivers the old paramter set only (from
code-line newpar - par(no.readonly=T)). If the code-segment newpar
- par(mar=... runs a second time, the correct paramter set is
stored, however, just the 5 parameters adjusted and not the full list.

My question is, why must the code segment newpar-par(mar...) run
twice? Is there a better way to handle the graphics output? I would be
grateful for a pointer on a FAQ-section or to an older discussion
thread in this group!

Thank you very much in advance!

Regards,
/steffen

--
Steffen Uhlig, PhD
Mechatronik und Sensortechnik
HTW des Saarlandes
Goebenstraße 40
66117 Saarbrücken

Tel.: +49 (0) 681 58 67 274

__
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.


[R] ps-output and LaTeX/DVIPS/PS2PDF - Greek letters disappear

2010-06-04 Thread Steffen Uhlig

Hello!

My graphs are produced using the postscript-option in R (R version 
2.10.1 (2009-12-14)). When Greek letters are used on the axis, 
everything looks fine in the *.ps-file. If included in a LaTeX-file and 
(on Ubuntu 10.04, fresh install), the Greek letters appear in the DVI- 
and PS-output, however, if converted with ps2pdf they suddenly 
disappear. Could anyone suggest a solution?


Best regards,
/steffen

--
Steffen Uhlig, PhD
Mechatronik und Sensortechnik
HTW des Saarlandes
Goebenstraße 40
66117 Saarbrücken

Tel.: +49 (0) 681 58 67 274

__
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.