[R] plotting question

2006-10-31 Thread Leeds, Mark \(IED\)
i have the following code below and at the end there are some plotting
statements.
it actualy looks quite nice when you run it but there is just one
strange thing  happening that
don't know how to fix.
 
the three things being plotted are
 
aggfxdata[,logbidask] which has its own set of times ( it's a zoo object
).
rollmeanlogbidask which has a subset of the times that aggfxdata has.
basically it starts later than aggfxdata[,logbidask] and when the plot
is done, it works in the
sense that rollmeanlogbidask gets plotted later.
 
then, i plot the variable lt on the same plot witrh it's vertical axis
on the right side and this works nicely also.
 
the only that doesn't quite work is that lt, time wise, lt,  starting at
the same time as the aggfxdata[,logbidask] when it should be starting a
few minutes after
rollmeanlogbidask. the times in it are correct and i don't think it has
to do with the fact that things are zoo ( but i could be wrong ? ).
i must be doing something wrong in my commands. the weird thing is that
rollmeanlogbidask starts at the appropriate place ?
 
maybe i have to give lt a different frequency but when i do the dput , i
don'ts ee freequency as part of it ?
 
this probably sounds way more confusing than it actually is but, if you
run below, you will see exactly what io mean. 
thanks a lot to anyone who can be bothered pasitng below. as usual, you
would need zoo and chron.
 
 
aggfxdata-structure(c(114.834516129032, 114.7922, 114.820808080808,
114.838260869565, 
114.837560975610, 114.776697247706, 114.7969, 114.745714285714, 
114.734923076923, 114.661939393939, 114.646574074074, 114.703486238532, 
114.646453900709, 114.651948051948, 114.742671755725, 114.721132075472, 
114.828647058824, 114.885978260870, 114.936860465116, 114.94, 
114.967763157895, 114.935107526882, 114.92225, 115.015606060606, 
115.077261146497, 115.034248366013, 114.961923076923, 114.976463414634, 
115.063468208092, 115.085882352941, 115.166847826087, 115.153306451613, 
115.137719298246, 115.080735294118, 115.074090909091, 115.021134751773, 
114.903450292398, 114.916153846154, 114.888306451613, 114.937469879518, 
114.890943396226, 114.849747899160, 114.926912751678, 114.874567901235, 
114.837980769231, 114.797538461538, 114.746707317073, 114.696013071895, 
114.67645833, 114.852184466019, 114.848548387097, 114.8078, 
114.835050505051, 114.851304347826, 114.852439024390, 114.792844036697, 
114.8117, 114.759206349206, 114.748307692308, 114.675939393939, 
114.661296296296, 114.717889908257, 114.660921985816, 114.665779220779, 
114.756870229008, 114.735471698113, 114.841941176471, 114.899184782609, 
114.949186046512, 114.953990384615, 114.982280701754, 114.948924731183, 
114.9368, 115.028863636364, 115.091592356688, 115.0478, 
114.975576923077, 114.990365853659, 115.078381502890, 115.099705882353, 
115.180326086957, 115.166370967742, 115.151052631579, 115.095147058824, 
115.088522727273, 115.035390070922, 114.917894736842, 114.930128205128, 
114.903790322581, 114.952409638554, 114.906226415094, 114.863865546218, 
114.940939597315, 114.890370370370, 114.852211538462, 114.812307692308, 
114.760548780488, 114.710326797386, 114.69020833, 114.866213592233, 
4.74355319771057, 4.74319148388547, 4.74343474081987, 4.74358150022944, 
4.74358339314172, 4.74305881517423, 4.74322922997911, 4.74277728938584, 
4.7426822736, 4.74204918880485, 4.7419183321792, 4.74241320264843, 
4.74191617575789, 4.74196131670693, 4.74275385322944, 4.74256674074965, 
4.74349887668465, 4.74399761812053, 4.74443655563793, 4.74447111073972, 
4.74471490416156, 4.74442779363424, 4.74431911442163, 4.74512545618279, 
4.74566600467616, 4.74528870019174, 4.74466035230505, 4.74478789738982, 
4.74554867613244, 4.74573870836097, 4.74644044208183, 4.74632106516708, 
4.74618687097407, 4.74569654200703, 4.74563889435559, 4.74517785826786, 
4.74415506578588, 4.74426356601777, 4.74402779250609, 4.74445322900522, 
4.74404986890124, 4.74368619357562, 4.7443574082389, 4.74390959824271, 
4.74358423039023, 4.7432343669113, 4.74278746542368, 4.74234766049834, 
4.74217470698038, 4.7437070219583), .Dim = c(50, 3), .Dimnames = list(
NULL, c(bid, ask, logbidask)), index = structure(c(1152058200,

1152058800, 1152059400, 115206, 1152060600, 1152061200, 1152061800, 
1152062400, 1152063000, 1152063600, 1152064200, 1152064800, 1152065400, 
1152066000, 1152066600, 1152067200, 1152067800, 1152068400, 1152069000, 
1152069600, 1152070200, 1152070800, 1152071400, 1152072000, 1152072600, 
1152073200, 1152073800, 1152074400, 1152075000, 1152075600, 1152076200, 
1152076800, 1152077400, 1152078000, 1152078600, 1152079200, 1152079800, 
1152080400, 1152081000, 1152081600, 1152082200, 1152082800, 1152083400, 
1152084000, 1152084600, 1152085200, 1152085800, 1152086400, 1152087000, 
1152087600), class = c(POSIXt, POSIXct)), class = zoo)

 
rollmeanlogbidask-structure(c(4.74371176689231, 4.74380800837135,
4.7439123277474, 
4.74400406541921, 4.7440745668118, 

Re: [R] plotting question

2006-10-31 Thread Gabor Grothendieck
I think you will have to ensure that lt has the same set of times as
the prior plot to do it that way.  Since time(lt) is a subset of
time(aggfxdata) it would be good enough to do this:

par(new = TRUE)
lt2 - merge(zoo(, time(aggfxdata)), lt)
plot(lt2, type = l, lty = 2)

On 10/31/06, Leeds, Mark (IED) [EMAIL PROTECTED] wrote:
 i have the following code below and at the end there are some plotting
 statements.
 it actualy looks quite nice when you run it but there is just one
 strange thing  happening that
 don't know how to fix.

 the three things being plotted are

 aggfxdata[,logbidask] which has its own set of times ( it's a zoo object
 ).
 rollmeanlogbidask which has a subset of the times that aggfxdata has.
 basically it starts later than aggfxdata[,logbidask] and when the plot
 is done, it works in the
 sense that rollmeanlogbidask gets plotted later.

 then, i plot the variable lt on the same plot witrh it's vertical axis
 on the right side and this works nicely also.

 the only that doesn't quite work is that lt, time wise, lt,  starting at
 the same time as the aggfxdata[,logbidask] when it should be starting a
 few minutes after
 rollmeanlogbidask. the times in it are correct and i don't think it has
 to do with the fact that things are zoo ( but i could be wrong ? ).
 i must be doing something wrong in my commands. the weird thing is that
 rollmeanlogbidask starts at the appropriate place ?

 maybe i have to give lt a different frequency but when i do the dput , i
 don'ts ee freequency as part of it ?

 this probably sounds way more confusing than it actually is but, if you
 run below, you will see exactly what io mean.
 thanks a lot to anyone who can be bothered pasitng below. as usual, you
 would need zoo and chron.


 aggfxdata-structure(c(114.834516129032, 114.7922, 114.820808080808,
 114.838260869565,
 114.837560975610, 114.776697247706, 114.7969, 114.745714285714,
 114.734923076923, 114.661939393939, 114.646574074074, 114.703486238532,
 114.646453900709, 114.651948051948, 114.742671755725, 114.721132075472,
 114.828647058824, 114.885978260870, 114.936860465116, 114.94,
 114.967763157895, 114.935107526882, 114.92225, 115.015606060606,
 115.077261146497, 115.034248366013, 114.961923076923, 114.976463414634,
 115.063468208092, 115.085882352941, 115.166847826087, 115.153306451613,
 115.137719298246, 115.080735294118, 115.074090909091, 115.021134751773,
 114.903450292398, 114.916153846154, 114.888306451613, 114.937469879518,
 114.890943396226, 114.849747899160, 114.926912751678, 114.874567901235,
 114.837980769231, 114.797538461538, 114.746707317073, 114.696013071895,
 114.67645833, 114.852184466019, 114.848548387097, 114.8078,
 114.835050505051, 114.851304347826, 114.852439024390, 114.792844036697,
 114.8117, 114.759206349206, 114.748307692308, 114.675939393939,
 114.661296296296, 114.717889908257, 114.660921985816, 114.665779220779,
 114.756870229008, 114.735471698113, 114.841941176471, 114.899184782609,
 114.949186046512, 114.953990384615, 114.982280701754, 114.948924731183,
 114.9368, 115.028863636364, 115.091592356688, 115.0478,
 114.975576923077, 114.990365853659, 115.078381502890, 115.099705882353,
 115.180326086957, 115.166370967742, 115.151052631579, 115.095147058824,
 115.088522727273, 115.035390070922, 114.917894736842, 114.930128205128,
 114.903790322581, 114.952409638554, 114.906226415094, 114.863865546218,
 114.940939597315, 114.890370370370, 114.852211538462, 114.812307692308,
 114.760548780488, 114.710326797386, 114.69020833, 114.866213592233,
 4.74355319771057, 4.74319148388547, 4.74343474081987, 4.74358150022944,
 4.74358339314172, 4.74305881517423, 4.74322922997911, 4.74277728938584,
 4.7426822736, 4.74204918880485, 4.7419183321792, 4.74241320264843,
 4.74191617575789, 4.74196131670693, 4.74275385322944, 4.74256674074965,
 4.74349887668465, 4.74399761812053, 4.74443655563793, 4.74447111073972,
 4.74471490416156, 4.74442779363424, 4.74431911442163, 4.74512545618279,
 4.74566600467616, 4.74528870019174, 4.74466035230505, 4.74478789738982,
 4.74554867613244, 4.74573870836097, 4.74644044208183, 4.74632106516708,
 4.74618687097407, 4.74569654200703, 4.74563889435559, 4.74517785826786,
 4.74415506578588, 4.74426356601777, 4.74402779250609, 4.74445322900522,
 4.74404986890124, 4.74368619357562, 4.7443574082389, 4.74390959824271,
 4.74358423039023, 4.7432343669113, 4.74278746542368, 4.74234766049834,
 4.74217470698038, 4.7437070219583), .Dim = c(50, 3), .Dimnames = list(
NULL, c(bid, ask, logbidask)), index = structure(c(1152058200,

 1152058800, 1152059400, 115206, 1152060600, 1152061200, 1152061800,
 1152062400, 1152063000, 1152063600, 1152064200, 1152064800, 1152065400,
 1152066000, 1152066600, 1152067200, 1152067800, 1152068400, 1152069000,
 1152069600, 1152070200, 1152070800, 1152071400, 1152072000, 1152072600,
 1152073200, 1152073800, 1152074400, 1152075000, 1152075600, 1152076200,
 1152076800, 1152077400, 1152078000, 1152078600, 

Re: [R] plotting question

2006-10-31 Thread Gavin Simpson
On Tue, 2006-10-31 at 12:08 -0500, Leeds, Mark (IED) wrote:
 i have the following code below and at the end there are some plotting
 statements.
 it actualy looks quite nice when you run it but there is just one
 strange thing  happening that
 don't know how to fix.

The problem you had, was that par(new = TRUE) # not T! resets the
plotting coordinate system, so even though the axis looks like it
extends the full range of the first data series, it covers the range of
lt, e.g.:

 plot(aggfxdata[,logbidask],main=,col=4)
 lines(rollmeanlogbidask,col=2)
 par(new=T)
 plot(lt,axes=F,type=l,lty=2)
 axis(side = 3) # new coords system

This works:

plot(aggfxdata[,logbidask], main = , col = 4)
lines(rollmeanlogbidask, col = 2)
usr - par(usr)
par(usr = c(usr[1:2], 0.76, 7.24))
lines(lt, lty = 2)
axis(4, at = pretty(range(lt)), tck = -0.02)

..., I think. But I cheat, because, here:

par(usr = c(usr[1:2], 0.76, 7.24))

I got the last two numbers by doing the following

 plot(lt)
 par(usr)[3:4]
[1] 0.76 7.24

A question then arises, how to process lt such that we end up with the
same numbers that R would have used to plot lt, i.e. which function or
bit of code will give:

 what.R.would.give(lt)
[1] 1.152076e+09 1.152088e+09 7.60e-01 7.24e+00

Without doing the plotting?

HTH

G

  
 the three things being plotted are
  
 aggfxdata[,logbidask] which has its own set of times ( it's a zoo object
 ).
 rollmeanlogbidask which has a subset of the times that aggfxdata has.
 basically it starts later than aggfxdata[,logbidask] and when the plot
 is done, it works in the
 sense that rollmeanlogbidask gets plotted later.
  
 then, i plot the variable lt on the same plot witrh it's vertical axis
 on the right side and this works nicely also.
  
 the only that doesn't quite work is that lt, time wise, lt,  starting at
 the same time as the aggfxdata[,logbidask] when it should be starting a
 few minutes after
 rollmeanlogbidask. the times in it are correct and i don't think it has
 to do with the fact that things are zoo ( but i could be wrong ? ).
 i must be doing something wrong in my commands. the weird thing is that
 rollmeanlogbidask starts at the appropriate place ?
  
 maybe i have to give lt a different frequency but when i do the dput , i
 don'ts ee freequency as part of it ?
  
 this probably sounds way more confusing than it actually is but, if you
 run below, you will see exactly what io mean. 
 thanks a lot to anyone who can be bothered pasitng below. as usual, you
 would need zoo and chron.
  
 
 aggfxdata-structure(c(114.834516129032, 114.7922, 114.820808080808,
 114.838260869565, 
 114.837560975610, 114.776697247706, 114.7969, 114.745714285714, 
 114.734923076923, 114.661939393939, 114.646574074074, 114.703486238532, 
 114.646453900709, 114.651948051948, 114.742671755725, 114.721132075472, 
 114.828647058824, 114.885978260870, 114.936860465116, 114.94, 
 114.967763157895, 114.935107526882, 114.92225, 115.015606060606, 
 115.077261146497, 115.034248366013, 114.961923076923, 114.976463414634, 
 115.063468208092, 115.085882352941, 115.166847826087, 115.153306451613, 
 115.137719298246, 115.080735294118, 115.074090909091, 115.021134751773, 
 114.903450292398, 114.916153846154, 114.888306451613, 114.937469879518, 
 114.890943396226, 114.849747899160, 114.926912751678, 114.874567901235, 
 114.837980769231, 114.797538461538, 114.746707317073, 114.696013071895, 
 114.67645833, 114.852184466019, 114.848548387097, 114.8078, 
 114.835050505051, 114.851304347826, 114.852439024390, 114.792844036697, 
 114.8117, 114.759206349206, 114.748307692308, 114.675939393939, 
 114.661296296296, 114.717889908257, 114.660921985816, 114.665779220779, 
 114.756870229008, 114.735471698113, 114.841941176471, 114.899184782609, 
 114.949186046512, 114.953990384615, 114.982280701754, 114.948924731183, 
 114.9368, 115.028863636364, 115.091592356688, 115.0478, 
 114.975576923077, 114.990365853659, 115.078381502890, 115.099705882353, 
 115.180326086957, 115.166370967742, 115.151052631579, 115.095147058824, 
 115.088522727273, 115.035390070922, 114.917894736842, 114.930128205128, 
 114.903790322581, 114.952409638554, 114.906226415094, 114.863865546218, 
 114.940939597315, 114.890370370370, 114.852211538462, 114.812307692308, 
 114.760548780488, 114.710326797386, 114.69020833, 114.866213592233, 
 4.74355319771057, 4.74319148388547, 4.74343474081987, 4.74358150022944, 
 4.74358339314172, 4.74305881517423, 4.74322922997911, 4.74277728938584, 
 4.7426822736, 4.74204918880485, 4.7419183321792, 4.74241320264843, 
 4.74191617575789, 4.74196131670693, 4.74275385322944, 4.74256674074965, 
 4.74349887668465, 4.74399761812053, 4.74443655563793, 4.74447111073972, 
 4.74471490416156, 4.74442779363424, 4.74431911442163, 4.74512545618279, 
 4.74566600467616, 4.74528870019174, 4.74466035230505, 4.74478789738982, 
 4.74554867613244, 4.74573870836097, 4.74644044208183, 4.74632106516708, 
 4.74618687097407, 4.74569654200703, 

Re: [R] plotting question

2006-10-31 Thread Gavin Simpson
On Tue, 2006-10-31 at 18:11 +, Gavin Simpson wrote:
 On Tue, 2006-10-31 at 12:08 -0500, Leeds, Mark (IED) wrote:
  i have the following code below and at the end there are some plotting
  statements.
  it actualy looks quite nice when you run it but there is just one
  strange thing  happening that
  don't know how to fix.
 
 The problem you had, was that par(new = TRUE) # not T! resets the
 plotting coordinate system, so even though the axis looks like it
 extends the full range of the first data series, it covers the range of
 lt, e.g.:
 
  plot(aggfxdata[,logbidask],main=,col=4)
  lines(rollmeanlogbidask,col=2)
  par(new=T)
  plot(lt,axes=F,type=l,lty=2)
  axis(side = 3) # new coords system
 
 This works:
 
 plot(aggfxdata[,logbidask], main = , col = 4)
 lines(rollmeanlogbidask, col = 2)
 usr - par(usr)
 par(usr = c(usr[1:2], 0.76, 7.24))
 lines(lt, lty = 2)
 axis(4, at = pretty(range(lt)), tck = -0.02)

Following off-list emails with Mark, I tracked down how to do this
automatically, for the thread...

It is document in ?par in the section on xaxs and yaxs (x and y axis
styles). This defaults to r, which adds/subtracts 4% to the x/ylims,
so,

plot(aggfxdata[,logbidask], main = , col = 4)
lines(rollmeanlogbidask, col = 2)
usr - par(usr)
# extend range of data by 4%
rany - (max(lt) - min(lt)) * 0.04
par(usr = c(usr[1:2], min(lt) - rany, max(lt) + rany))
lines(lt, lty = 2)
axis(4, at = pretty(range(lt)), tck = -0.02)

the above does exactly as I'd done before, but automagically.

G

 
 ..., I think. But I cheat, because, here:
 
 par(usr = c(usr[1:2], 0.76, 7.24))
 
 I got the last two numbers by doing the following
 
  plot(lt)
  par(usr)[3:4]
 [1] 0.76 7.24
 
 A question then arises, how to process lt such that we end up with the
 same numbers that R would have used to plot lt, i.e. which function or
 bit of code will give:
 
  what.R.would.give(lt)
 [1] 1.152076e+09 1.152088e+09 7.60e-01 7.24e+00
 
 Without doing the plotting?
 
 HTH
 
 G
 
   
  the three things being plotted are
   
  aggfxdata[,logbidask] which has its own set of times ( it's a zoo object
  ).
  rollmeanlogbidask which has a subset of the times that aggfxdata has.
  basically it starts later than aggfxdata[,logbidask] and when the plot
  is done, it works in the
  sense that rollmeanlogbidask gets plotted later.
   
  then, i plot the variable lt on the same plot witrh it's vertical axis
  on the right side and this works nicely also.
   
  the only that doesn't quite work is that lt, time wise, lt,  starting at
  the same time as the aggfxdata[,logbidask] when it should be starting a
  few minutes after
  rollmeanlogbidask. the times in it are correct and i don't think it has
  to do with the fact that things are zoo ( but i could be wrong ? ).
  i must be doing something wrong in my commands. the weird thing is that
  rollmeanlogbidask starts at the appropriate place ?
   
  maybe i have to give lt a different frequency but when i do the dput , i
  don'ts ee freequency as part of it ?
   
  this probably sounds way more confusing than it actually is but, if you
  run below, you will see exactly what io mean. 
  thanks a lot to anyone who can be bothered pasitng below. as usual, you
  would need zoo and chron.
   
  
  aggfxdata-structure(c(114.834516129032, 114.7922, 114.820808080808,
  114.838260869565, 
  114.837560975610, 114.776697247706, 114.7969, 114.745714285714, 
  114.734923076923, 114.661939393939, 114.646574074074, 114.703486238532, 
  114.646453900709, 114.651948051948, 114.742671755725, 114.721132075472, 
  114.828647058824, 114.885978260870, 114.936860465116, 114.94, 
  114.967763157895, 114.935107526882, 114.92225, 115.015606060606, 
  115.077261146497, 115.034248366013, 114.961923076923, 114.976463414634, 
  115.063468208092, 115.085882352941, 115.166847826087, 115.153306451613, 
  115.137719298246, 115.080735294118, 115.074090909091, 115.021134751773, 
  114.903450292398, 114.916153846154, 114.888306451613, 114.937469879518, 
  114.890943396226, 114.849747899160, 114.926912751678, 114.874567901235, 
  114.837980769231, 114.797538461538, 114.746707317073, 114.696013071895, 
  114.67645833, 114.852184466019, 114.848548387097, 114.8078, 
  114.835050505051, 114.851304347826, 114.852439024390, 114.792844036697, 
  114.8117, 114.759206349206, 114.748307692308, 114.675939393939, 
  114.661296296296, 114.717889908257, 114.660921985816, 114.665779220779, 
  114.756870229008, 114.735471698113, 114.841941176471, 114.899184782609, 
  114.949186046512, 114.953990384615, 114.982280701754, 114.948924731183, 
  114.9368, 115.028863636364, 115.091592356688, 115.0478, 
  114.975576923077, 114.990365853659, 115.078381502890, 115.099705882353, 
  115.180326086957, 115.166370967742, 115.151052631579, 115.095147058824, 
  115.088522727273, 115.035390070922, 114.917894736842, 114.930128205128, 
  114.903790322581, 114.952409638554, 114.906226415094, 114.863865546218, 
  114.940939597315, 

[R] plotting question

2006-10-31 Thread Leeds, Mark \(IED\)
i have the axis line of code  below in a plotting command and it works
nicely  but it puts tick values at every 5 of lt and i would like a tick
value at every value of lt. i read about pretty() but that sounded
tricky so instead , since i want a tick mark at every value of lt ( it's
discrete and goes from o to some max value usually arounsd 35 or 40 )
 
i changed the line to  at = seq(1,max(lt) ) but that gave me no
tickmarks ?
 
any help is appreciated. thanks.
 
#---

 
axis(4, at = pretty(range(lt)),line=0.75,tick=TRUE)
 
#---
--


This is not an offer (or solicitation of an offer) to buy/sell the 
securities/instruments mentioned or an official confirmation.  Morgan Stanley 
may deal as principal in or own or act as market maker for 
securities/instruments mentioned or may advise the issuers.  This is not 
research and is not from MS Research but it may refer to a research 
analyst/research report.  Unless indicated, these views are the author's and 
may differ from those of Morgan Stanley research or others in the Firm.  We do 
not represent this is accurate or complete and we may not update this.  Past 
performance is not indicative of future returns.  For additional information, 
research reports and important disclosures, contact me or see 
https://secure.ms.com/servlet/cls.  You should not use e-mail to request, 
authorize or effect the purchase or sale of any security or instrument, to send 
transfer instructions, or to effect any other transactions.  We cannot 
guarantee that any such requests received via !
 e-mail will be processed in a timely manner.  This communication is solely for 
the addressee(s) and may contain confidential information.  We do not waive 
confidentiality by mistransmission.  Contact me if you do not wish to receive 
these communications.  In the UK, this communication is directed in the UK to 
those persons who are market counterparties or intermediate customers (as 
defined in the UK Financial Services Authority's rules).

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] plotting question

2006-10-31 Thread Gavin Simpson
On Tue, 2006-10-31 at 16:52 -0500, Leeds, Mark (IED) wrote:
 i have the axis line of code  below in a plotting command and it works
 nicely  but it puts tick values at every 5 of lt and i would like a tick
 value at every value of lt. i read about pretty() but that sounded
 tricky so instead , since i want a tick mark at every value of lt ( it's
 discrete and goes from o to some max value usually arounsd 35 or 40 )
  
 i changed the line to  at = seq(1,max(lt) ) but that gave me no
 tickmarks ?

?unique

 lt - sample(1:40, 50, replace = TRUE) # dummy data
 lt
 [1] 37 30 38 33 13 19  6 39 15 21  5 11  5  5 32  1 23 20 12 21 35 32
34 26 39
[26] 30 11 36 26 12 37 27 26  9 23  2 24  4 20  3  1  7 27 37 31 25 38
29 29 17
 plot(lt, type = l)
 axis(4, at = unique(lt))

Looks a bit weird because of the number of unique values in lt, but will
look OK with the data series you posted earlier.

Also, 

 plot(lt, type = l)
 axis(4, at = pretty(range(lt)),line=0.75,tick=TRUE)

doesn't look right on my default device, do you really want to move the
axis away from the plot margin?

HTH

G

  
 any help is appreciated. thanks.
  
 #---
 
  
 axis(4, at = pretty(range(lt)),line=0.75,tick=TRUE)
  
 #---
 --
 
 
 This is not an offer (or solicitation of an offer) to buy/sell the 
 securities/instruments mentioned or an official confirmation.  Morgan Stanley 
 may deal as principal in or own or act as market maker for 
 securities/instruments mentioned or may advise the issuers.  This is not 
 research and is not from MS Research but it may refer to a research 
 analyst/research report.  Unless indicated, these views are the author's and 
 may differ from those of Morgan Stanley research or others in the Firm.  We 
 do not represent this is accurate or complete and we may not update this.  
 Past performance is not indicative of future returns.  For additional 
 information, research reports and important disclosures, contact me or see 
 https://secure.ms.com/servlet/cls.  You should not use e-mail to request, 
 authorize or effect the purchase or sale of any security or instrument, to 
 send transfer instructions, or to effect any other transactions.  We cannot 
 guarantee that any such requests received vi!
 a !
  e-mail will be processed in a timely manner.  This communication is solely 
 for the addressee(s) and may contain confidential information.  We do not 
 waive confidentiality by mistransmission.  Contact me if you do not wish to 
 receive these communications.  In the UK, this communication is directed in 
 the UK to those persons who are market counterparties or intermediate 
 customers (as defined in the UK Financial Services Authority's rules).
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC  ENSIS, 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/cv/
 London, UK. WC1E 6BT. [w] http://www.ucl.ac.uk/~ucfagls/
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@stat.math.ethz.ch 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] plotting question

2006-09-19 Thread Steve Friedman
Hello list,

I am interested in plotting a series of barcharts (package lattice) with
several metrics. Instead of calling barchart many times to call each
parameter, is there an approach to calling several parameters at once?

An alternative might be a barplot for a primary parameter and then adding a
line or second axis for a second parameter.

Thanks in advance


-- 
Steve Friedman
Center for Global Change and Earth Observations
Michigan State University
Envisioning Ecosystem Decisions

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] plotting question

2006-09-19 Thread Richard M. Heiberger
Is this what you have in mind?


tmp - data.frame(id=1:10, y1=sample(10), y2=sample(10))

tmp2 - cbind(id=c(tmp$id, tmp$id), stack(tmp[,2:3]))

barchart(values ~ id | ind, data=tmp2)



If not, send an equally trivial example of what you want to the list
and someone will send you an optimized set of statements for it.

__
R-help@stat.math.ethz.ch 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] plotting question

2005-12-05 Thread Ed Wang
Hi,

Trying to print out two vectors of data in a plot.  Both are
actual time series but I've been unable to plot both in one
graph.  Some examples available use use matrix() or ts() as
an intermediate way to build an object that can be plotted
but I've had no luck.

Can someone point me to an example or cut and paste one
I can look at?  I'd like to be able to plot them in different
colours as I've done with the ts.plot function with output
from STL.

Thanks.

Ed

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] plotting question

2005-12-05 Thread Berton Gunter
?lines ?points

An Introduction to R (and numerous other books on R) explains this. Have you
read it?


-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Ed Wang
 Sent: Monday, December 05, 2005 1:03 PM
 To: r-help@stat.math.ethz.ch
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] plotting question
 
 Hi,
 
 Trying to print out two vectors of data in a plot.  Both are
 actual time series but I've been unable to plot both in one
 graph.  Some examples available use use matrix() or ts() as
 an intermediate way to build an object that can be plotted
 but I've had no luck.
 
 Can someone point me to an example or cut and paste one
 I can look at?  I'd like to be able to plot them in different
 colours as I've done with the ts.plot function with output
 from STL.
 
 Thanks.
 
 Ed
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] plotting question

2005-12-05 Thread Ed Wang
Yes, I have gone through the manual.  My best reference for plotting has
been examples either through the list archive or searches on the internet.
Nothing in the introductory manual could get me to what I have been
able to do so far, but that is limited to plotting componenets of the time
series returned from an STL call.

This is why I am asking for example or references to examples from anyone
who would be willing to share them.  For some of us not very familiar with
S+, etc. the documentation with R is not enough.  While I can plot two
time series one above another using the mfrow() function I'd prefer to
put two time series in one plot in different colours and using two different
symbols, which I cannot do using calls to plot().

Thanks.

   A man is not old until regrets take the place of dreams.
 Actor John Barrymore




From: Berton Gunter [EMAIL PROTECTED]
To: 'Ed Wang' [EMAIL PROTECTED], r-help@stat.math.ethz.ch
Subject: RE: [R] plotting question
Date: Mon, 5 Dec 2005 14:12:47 -0800
?lines ?points

An Introduction to R (and numerous other books on R) explains this. Have you
read it?


-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA

The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] plotting question

2005-12-05 Thread Gabor Grothendieck
Try

RSiteSearch(multiple plots)

and look through the second thread.  Note that once you
know the command you need from the above then, e.g.

example(ts.plot)

gives an example.


On 12/5/05, Ed Wang [EMAIL PROTECTED] wrote:
 Yes, I have gone through the manual.  My best reference for plotting has
 been examples either through the list archive or searches on the internet.
 Nothing in the introductory manual could get me to what I have been
 able to do so far, but that is limited to plotting componenets of the time
 series returned from an STL call.

 This is why I am asking for example or references to examples from anyone
 who would be willing to share them.  For some of us not very familiar with
 S+, etc. the documentation with R is not enough.  While I can plot two
 time series one above another using the mfrow() function I'd prefer to
 put two time series in one plot in different colours and using two different
 symbols, which I cannot do using calls to plot().

 Thanks.

   A man is not old until regrets take the place of dreams.
 Actor John Barrymore




 From: Berton Gunter [EMAIL PROTECTED]
 To: 'Ed Wang' [EMAIL PROTECTED], r-help@stat.math.ethz.ch
 Subject: RE: [R] plotting question
 Date: Mon, 5 Dec 2005 14:12:47 -0800
 ?lines ?points

 An Introduction to R (and numerous other books on R) explains this. Have you
 read it?


 -- Bert Gunter
 Genentech Non-Clinical Statistics
 South San Francisco, CA

 The business of the statistician is to catalyze the scientific learning
 process.  - George E. P. Box

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] plotting question

2005-12-05 Thread Kjetil Brinchmann Halvorsen
Ed Wang wrote:
 Yes, I have gone through the manual.  My best reference for plotting has
 been examples either through the list archive or searches on the internet.
 Nothing in the introductory manual could get me to what I have been
 able to do so far, but that is limited to plotting componenets of the time
 series returned from an STL call.
 
 This is why I am asking for example or references to examples from anyone
 who would be willing to share them.  For some of us not very familiar with
 S+, etc. the documentation with R is not enough.  While I can plot two
 time series one above another using the mfrow() function I'd prefer to
 put two time series in one plot in different colours and using two different
 symbols, which I cannot do using calls to plot().

What about making the two time series into an mts (multiple time series)
object, with
my.mts -  cbind(ts.1, ts.2)   or maybe
my.ts  -  ts.union(ts.1, ts.2)This latest command does not assume a 
commomtime base.   Then
plot(my.ts,plot.type=single, col=c(red, blue))

Kjetil

 
 Thanks.
 
A man is not old until regrets take the place of dreams.
  Actor John Barrymore
 
 
 
 
 From: Berton Gunter [EMAIL PROTECTED]
 To: 'Ed Wang' [EMAIL PROTECTED], r-help@stat.math.ethz.ch
 Subject: RE: [R] plotting question
 Date: Mon, 5 Dec 2005 14:12:47 -0800
 ?lines ?points
 
 An Introduction to R (and numerous other books on R) explains this. Have you
 read it?
 
 
 -- Bert Gunter
 Genentech Non-Clinical Statistics
 South San Francisco, CA
 
 The business of the statistician is to catalyze the scientific learning
 process.  - George E. P. Box
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] plotting question

2005-12-05 Thread paul sorenson
Ed,

I am no expert at R but if you follow the tips from the previous poster 
(eg type ?lines) and go to the very bottom of the help page there is an 
example that plots a line over some points.

cheers

Ed Wang wrote:
 Yes, I have gone through the manual.  My best reference for plotting has
 been examples either through the list archive or searches on the internet.
 Nothing in the introductory manual could get me to what I have been
 able to do so far, but that is limited to plotting componenets of the time
 series returned from an STL call.
 
 This is why I am asking for example or references to examples from anyone
 who would be willing to share them.  For some of us not very familiar with
 S+, etc. the documentation with R is not enough.  While I can plot two
 time series one above another using the mfrow() function I'd prefer to
 put two time series in one plot in different colours and using two different
 symbols, which I cannot do using calls to plot().
 
 Thanks.
 
A man is not old until regrets take the place of dreams.
  Actor John Barrymore
 
 
 
 
 From: Berton Gunter [EMAIL PROTECTED]
 To: 'Ed Wang' [EMAIL PROTECTED], r-help@stat.math.ethz.ch
 Subject: RE: [R] plotting question
 Date: Mon, 5 Dec 2005 14:12:47 -0800
 ?lines ?points
 
 An Introduction to R (and numerous other books on R) explains this. Have you
 read it?
 
 
 -- Bert Gunter
 Genentech Non-Clinical Statistics
 South San Francisco, CA
 
 The business of the statistician is to catalyze the scientific learning
 process.  - George E. P. Box
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Plotting question

2004-02-05 Thread Erin Hodgess
Hi Felix:

How about this:
 n1.Plot
function(x,my=0,sigma=1) {
f.x - dnorm(x,mean=my,sd=sigma)
plot(x,f.x,type=l,xlim=c(-5,5))
return(f.x)
}

Hope this helps!
Sincerely,
Erin Hodgess
mailto: [EMAIL PROTECTED]



i have written this little function to draw different normal distributions:

n.Plot - function(x,my,sigma) {
e - exp(1)
names(x) - x
f.x - (1/(sigma*sqrt(2*pi)))*e^(-1*(((x-my)^2)/2*(sigma^2)))
plot(f.x,type=l,xlim=c(-5,5))
return(f.x)
}

if i define x like this:
x - seq(-5,5,0.01)

Now 
n.Plot(x,0,1) 
DOES draw the correct plot, but the x-axis is labeled from 0 - 1000.
If i give the plot function the xlim=c(-5,5) option, the plot is only drawn 
for the first 5 values of x.
How do i tell plot not to take the indices of x, but the values (or their 
range) of x for labeling the x-axis ?

Felix Eschenburg

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] plotting question: filling area between two lines

2003-02-25 Thread Christof Bigler
Is there any way to fill the area within a plotted line and a 
horizontal line, e.g. in the following example:

x - rnorm(100)
plot(x,type=l)
abline(h=0)
Thanks for any help.

Christof

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] plotting question: filling area between two lines

2003-02-25 Thread Achim Zeileis
On Tuesday 25 February 2003 17:51, Christof Bigler wrote:

 Is there any way to fill the area within a plotted line and a
 horizontal line, e.g. in the following example:

 x - rnorm(100)
 plot(x,type=l)
 abline(h=0)

You could do
   polygon(c(1, 1:100, 100), c(0, x, 0), col = grey)
in the above example.
Z

 Thanks for any help.

 Christof

 __
 [EMAIL PROTECTED] mailing list
 http://www.stat.math.ethz.ch/mailman/listinfo/r-help

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Plotting Question

2003-01-16 Thread Coate, Bruce
For a clinical trial I am involved with, I would like a plot (for each
subject) similar to the following which will indicate what drugs that
subject was taking on each day during the study:

Drug 1[---]   [--]

Drug 2[-]

Drug 3   [-]  []
 |--|
 0n

   Study Day

 I have thought about using strip plot, perhaps setting a flag each day the
subject is on study (1 if drug x is taken on that day, NA otherwise). But
that means I would have to create extra records for each subject because my
data looks something like,

Subject   Drug   Start  Stop
--
 1   1 5Jan2002   10Jan2002
 1   112Jan2002  30Jan2002
 2   215Feb2002  20Mar2002
etc.

Does anyone have a suggestion as to which kind of plotting function is best
suited to this? 
Thanks.

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help



Re: [R] Plotting Question

2003-01-16 Thread Frank E Harrell Jr
You might investigate the event.chart function in the Hmisc library (see 
http://hesweb1.med.virginia.edu/biostat/s/Hmisc.html)

On Thu, 16 Jan 2003 08:10:34 -0800
Coate, Bruce [EMAIL PROTECTED] wrote:

 For a clinical trial I am involved with, I would like a plot (for each
 subject) similar to the following which will indicate what drugs that
 subject was taking on each day during the study:
 
 Drug 1[---]   [--]
 
 Drug 2[-]
 
 Drug 3   [-]  []
  |--|
  0n
 
Study Day
 
  I have thought about using strip plot, perhaps setting a flag each day the
 subject is on study (1 if drug x is taken on that day, NA otherwise). But
 that means I would have to create extra records for each subject because my
 data looks something like,
 
 Subject   Drug   Start  Stop
 --
  1   1 5Jan2002   10Jan2002
  1   112Jan2002  30Jan2002
  2   215Feb2002  20Mar2002
 etc.
 
 Does anyone have a suggestion as to which kind of plotting function is best
 suited to this? 
 Thanks.
 
 __
 [EMAIL PROTECTED] mailing list
 http://www.stat.math.ethz.ch/mailman/listinfo/r-help


-- 
Frank E Harrell Jr  Prof. of Biostatistics  Statistics
Div. of Biostatistics  Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine  http://hesweb1.med.virginia.edu/biostat

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help