Re: [R] Programming Question (setting ylim generally)

2009-01-09 Thread Gavin Simpson
On Fri, 2009-01-09 at 00:22 -0500, stephen sefick wrote:
 library(StreamMetabolism)
snip /
 plot.e - function(b, w, x, y, z){
 a - window.chron(b, w, x, y, z)
 low - min(b*0.98)+5
 high - max(b*1.02)+5
 plot(a, ylim=c(low, high))
 lines(a*0.98, col=blue)
 lines(a*1.02, col=red)
 }
 
 plot.e(day, 03/28/2007, 00:00:00, 03/28/2007, 23:46:00)
 
 why do the low and high objects not set the ylim of the plotting function?

Err, they do. You are plotting 'a' which has (whilst debugging your
plot.e() )

Browse[1] range(a)
[1]  9.93 11.15

You set the ylims to be (computed from 'b', why if plotting 'a'? and why
is 'low' +5, should it be -5?):

Browse[1] low
[1] 14.7314
Browse[1] high
[1] 16.373

And the plot I get has pretty labels/ticks that lie between 14.7 and
16.3, but as the plotted data lie outside the range of the y-axis you
don't see anything.

The figure is actually drawn with a bit of extra (4%) fudge on the x and
y limits as that is how all R plot work by default due to parameters
'xaxs' and 'yaxs'. If you want them to be exactly 'low' and 'high' then
setting yaxs=i might help. See ?par

I suspect your plot.e needs to be something like this:

`plot.e` - function(b, w, x, y, z){
a - window.chron(b, w, x, y, z)
low - min(a*0.98)-5
high - max(a*1.02)+5
plot(a, ylim=c(low, high))
lines(a*0.98, col=blue)
lines(a*1.02, col=red)
}

So you are computing your ylims on a and you make low = foo - 5 not + 5.
At least then the lines you are drawing are displayed on the figure
region - the +/-5 in low and high seem a bit extreme, but that was what
you had so...

HTH

G
 
 thanks
 
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



signature.asc
Description: This is a digitally signed message part
__
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] Programming Question (setting ylim generally)

2009-01-09 Thread stephen sefick
WOW, I am not going to post after midnight.  Thank you for your
response, and this is what I settled on.

`plot.e` - function(b, w, x, y, z){
a - window.chron(b, w, x, y, z)
low - min(a*0.98)-(min(a)*0.04)
high - max(a*1.02)+(max(a)*0.04)
plot(a, ylim=c(low, high))
lines(a*0.98, col=blue)
lines(a*1.02, col=red)
}

On Fri, Jan 9, 2009 at 5:38 AM, Gavin Simpson gavin.simp...@ucl.ac.uk wrote:
 On Fri, 2009-01-09 at 00:22 -0500, stephen sefick wrote:
 library(StreamMetabolism)
 snip /
 plot.e - function(b, w, x, y, z){
 a - window.chron(b, w, x, y, z)
 low - min(b*0.98)+5
 high - max(b*1.02)+5
 plot(a, ylim=c(low, high))
 lines(a*0.98, col=blue)
 lines(a*1.02, col=red)
 }

 plot.e(day, 03/28/2007, 00:00:00, 03/28/2007, 23:46:00)

 why do the low and high objects not set the ylim of the plotting function?

 Err, they do. You are plotting 'a' which has (whilst debugging your
 plot.e() )

 Browse[1] range(a)
 [1]  9.93 11.15

 You set the ylims to be (computed from 'b', why if plotting 'a'? and why
 is 'low' +5, should it be -5?):

 Browse[1] low
 [1] 14.7314
 Browse[1] high
 [1] 16.373

 And the plot I get has pretty labels/ticks that lie between 14.7 and
 16.3, but as the plotted data lie outside the range of the y-axis you
 don't see anything.

 The figure is actually drawn with a bit of extra (4%) fudge on the x and
 y limits as that is how all R plot work by default due to parameters
 'xaxs' and 'yaxs'. If you want them to be exactly 'low' and 'high' then
 setting yaxs=i might help. See ?par

 I suspect your plot.e needs to be something like this:

 `plot.e` - function(b, w, x, y, z){
 a - window.chron(b, w, x, y, z)
 low - min(a*0.98)-5
 high - max(a*1.02)+5
 plot(a, ylim=c(low, high))
 lines(a*0.98, col=blue)
 lines(a*1.02, col=red)
 }

 So you are computing your ylims on a and you make low = foo - 5 not + 5.
 At least then the lines you are drawing are displayed on the figure
 region - the +/-5 in low and high seem a bit extreme, but that was what
 you had so...

 HTH

 G

 thanks

 --
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
  Dr. Gavin Simpson [t] +44 (0)20 7679 0522
  ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
  Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
  Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
  UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%





-- 
Stephen Sefick

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

__
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] Programming Question (setting ylim generally)

2009-01-09 Thread Mike Prager
stephen sefick ssef...@gmail.com wrote:

 low - min(a*0.98)-(min(a)*0.04)
 high - max(a*1.02)+(max(a)*0.04)
 plot(a, ylim=c(low, high))

Unless I am misreading your example, this can be done a little
more compactly as:

plot(a, ylim = range(a * 0.94, a * 1.06))

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

__
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] Programming Question (setting ylim generally)

2009-01-09 Thread Gabor Grothendieck
Or even:

plot(a, ylim = range(a) + 0.06 * c(-1, 1))


On Fri, Jan 9, 2009 at 2:07 PM, Mike Prager mike.pra...@noaa.gov wrote:
 stephen sefick ssef...@gmail.com wrote:

 low - min(a*0.98)-(min(a)*0.04)
 high - max(a*1.02)+(max(a)*0.04)
 plot(a, ylim=c(low, high))

 Unless I am misreading your example, this can be done a little
 more compactly as:

 plot(a, ylim = range(a * 0.94, a * 1.06))

 --
 Mike Prager, NOAA, Beaufort, NC
 * Opinions expressed are personal and not represented otherwise.
 * Any use of tradenames does not constitute a NOAA endorsement.

 __
 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-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] Programming Question (setting ylim generally)

2009-01-09 Thread stephen sefick
WOW, Gabor, that is fancy.  I have gotten better at this R thing, but
have far to go.  That is a neat solution.
thanks

Stephen


On Fri, Jan 9, 2009 at 2:22 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Or even:

 plot(a, ylim = range(a) + 0.06 * c(-1, 1))


 On Fri, Jan 9, 2009 at 2:07 PM, Mike Prager mike.pra...@noaa.gov wrote:
 stephen sefick ssef...@gmail.com wrote:

 low - min(a*0.98)-(min(a)*0.04)
 high - max(a*1.02)+(max(a)*0.04)
 plot(a, ylim=c(low, high))

 Unless I am misreading your example, this can be done a little
 more compactly as:

 plot(a, ylim = range(a * 0.94, a * 1.06))

 --
 Mike Prager, NOAA, Beaufort, NC
 * Opinions expressed are personal and not represented otherwise.
 * Any use of tradenames does not constitute a NOAA endorsement.

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




-- 
Stephen Sefick

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

__
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] Programming Question (setting ylim generally)

2009-01-09 Thread Gabor Grothendieck
Berwin Turlach has pointed out that to
be equivalent to the original answer the
code should be:

plot(a, ylim = range(a) * (1 + 0.06 * c(-1,1)))

On Fri, Jan 9, 2009 at 2:22 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Or even:

 plot(a, ylim = range(a) + 0.06 * c(-1, 1))


 On Fri, Jan 9, 2009 at 2:07 PM, Mike Prager mike.pra...@noaa.gov wrote:
 stephen sefick ssef...@gmail.com wrote:

 low - min(a*0.98)-(min(a)*0.04)
 high - max(a*1.02)+(max(a)*0.04)
 plot(a, ylim=c(low, high))

 Unless I am misreading your example, this can be done a little
 more compactly as:

 plot(a, ylim = range(a * 0.94, a * 1.06))

 --
 Mike Prager, NOAA, Beaufort, NC
 * Opinions expressed are personal and not represented otherwise.
 * Any use of tradenames does not constitute a NOAA endorsement.

 __
 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-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] Programming Question (setting ylim generally)

2009-01-08 Thread stephen sefick
library(StreamMetabolism)

day - (structure(c(10.08, 10.08, 10.05, 10.03, 10, 9.98, 9.96, 9.95,
9.95, 9.96, 9.96, 9.98, 10.01, 10.05, 10.06, 10.09, 10.11, 10.11,
10.13, 10.13, 10.15, 10.15, 10.13, 10.14, 10.11, 10.13, 10.14,
10.13, 10.12, 10.13, 10.14, 10.16, 10.18, 10.19, 10.23, 10.27,
10.33, 10.37, 10.45, 10.57, 10.6, 10.66, 10.73, 10.77, 10.84,
10.86, 10.87, 10.94, 10.98, 11.01, 11.05, 11.09, 11.11, 11.12,
11.14, 11.13, 11.15, 11.14, 11.13, 11.13, 11.12, 11.09, 11.08,
11.07, 11.05, 11.04, 11.03, 11.01, 10.99, 11, 10.94, 10.91, 10.86,
10.82, 10.77, 10.73, 10.7, 10.63, 10.59, 10.54, 10.47, 10.37,
10.3, 10.23, 10.18, 10.13, 10.09, 10.05, 10.02, 9.98, 9.96, 9.95,
9.94, 9.93, 9.94, 9.97), index = structure(c(13600.000694,
13600.01, 13600.021528, 13600.031944, 13600.042361,
13600.052778, 13600.063194, 13600.073611, 13600.084028,
13600.09, 13600.104861, 13600.115278, 13600.125694,
13600.136111, 13600.146528, 13600.156944, 13600.167361,
13600.18, 13600.188194, 13600.198611, 13600.209028,
13600.219444, 13600.229861, 13600.240278, 13600.250694,
13600.26, 13600.271528, 13600.281944, 13600.292361,
13600.302778, 13600.313194, 13600.323611, 13600.334028,
13600.34, 13600.354861, 13600.365278, 13600.375694,
13600.386111, 13600.396528, 13600.406944, 13600.417361,
13600.427778, 13600.438194, 13600.448611, 13600.459028,
13600.469444, 13600.479861, 13600.490278, 13600.500694,
13600.51, 13600.521528, 13600.531944, 13600.542361,
13600.552778, 13600.563194, 13600.573611, 13600.584028,
13600.59, 13600.604861, 13600.615278, 13600.625694,
13600.636111, 13600.646528, 13600.656944, 13600.667361,
13600.68, 13600.688194, 13600.698611, 13600.709028,
13600.719444, 13600.729861, 13600.740278, 13600.750694,
13600.76, 13600.771528, 13600.781944, 13600.792361,
13600.802778, 13600.813194, 13600.823611, 13600.834028,
13600.84, 13600.854861, 13600.865278, 13600.875694,
13600.886111, 13600.896528, 13600.906944, 13600.917361,
13600.927778, 13600.938194, 13600.948611, 13600.959028,
13600.969444, 13600.979861, 13600.990278), format =
structure(c(m/d/y,
h:m:s), .Names = c(dates, times)), origin = structure(c(1,
1, 1970), .Names = c(month, day, year)), class = c(chron,
dates, times)), class = zoo))

plot.e - function(b, w, x, y, z){
a - window.chron(b, w, x, y, z)
low - min(b*0.98)+5
high - max(b*1.02)+5
plot(a, ylim=c(low, high))
lines(a*0.98, col=blue)
lines(a*1.02, col=red)
}

plot.e(day, 03/28/2007, 00:00:00, 03/28/2007, 23:46:00)

why do the low and high objects not set the ylim of the plotting function?

thanks

-- 
Stephen Sefick

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

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