I've been having a heck of a time plotting vertical lines in a lattice plot and
can't seem to get any traction on how to accomplish this seemingly simple task.
I have a lattice plot:
p <- xyplot( nassets ~ backtestdate | as.factor( port.label ) + as.factor(
target.return.label ),
groups=daysback,
data=univ,
type="l",
ylab="Number of Assets",
xlab="Time",
col=c("red","green","blue"),
lty=c(1,1,1),
index.cond=list(c(2,1),c(2,1)),
scales = list(x = list(alternating = 3), y = list(alternating = 3)
),
layout=c(2,2),
main=sprintf( "Number of Assets in Portfolio" ),
panel = function(x, y,...) {
## put the months as vertical lines
panel.grid(h=-1, v=0) ## lay down horizontal lines
panel.xyplot(x, y, ...)
## these don't work
## panel.abline(h=NULL, v=c(1,10,20,30,40,50,60),
reference=FALSE,... )
## panel.abline(h=NULL, v=c(1,10,20,30,40,50,60),
reference=TRUE,... )
## these don't work
## panel.abline(h=NULL,
v=c("2010-07-02","2010-08-02","2010-09-01","2010-10-01"), reference=FALSE, ... )
## panel.abline(h=NULL,
v=c("2010-07-02","2010-08-02","2010-09-01","2010-10-01"), reference=TRUE, ... )
## these don't work either.. grrrr...
##panel.grid(h=-1,
v=c("2010-07-02","2010-08-02","2010-09-01","2010-10-01"), reference=TRUE )
##panel.abline(h=NULL, v=c(1,21,43,64), reference=FALSE )
##panel.abline(h=NULL,
v=c("2010-07-02","2010-08-02","2010-09-01","2010-10-01"), reference=TRUE,... )
},
key=list(space="bottom",
title="Days Included in Calculation",
text=list(c("50","100","200")),
lines=c(1,1,1),
lty=c(1,1,1),
col=c("red","green","blue"),
columns=3)
)
print( p )
And I would like to add dotted lines on the months/years like the
fPortfolioBacktest package does.
I think my issue with the xyplot version.
Solutions?
Respectfully,
Jeff.
Jeff D. Hamann, PhD
2430 NW Professional Drive
Corvallis, Oregon 97330
877-421-9815
jeff.hamann[at]moneytree[dot]com
http://www.moneytree.com
Full featured flexible financial plans in minutes.
Simple or advanced. Goal or cash flow. Desktop or online.
Free downloads, videos, & online trials.
[[alternative HTML version deleted]]
_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should
go.