Hi all I have a plot with lines, one specified as (say) lty=1, using standard line types, and another as (say) my own spec: lty="51". I can't get legend to display both. Toy example:> plot(1~1) > legend("topright", lty=c("51",1), legend=c("My own","Standard"))Error in segments(x1, y1, x2, y2, ...) : invalid line type: must be length 2, 4, 6 or 8>Any ideas? P.> sessionInfo()R version 2.5.0 (2007-04-23) i386-pc-mingw32 locale: LC_COLLATE=English_Australia.1252;LC_CTYPE=English_Australia.1252;LC_MON ETARY=English_Australia.1252;LC_NUMERIC=C;LC_TIME=English_Australia.1252 attached base packages: [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" "base" other attached packages: car xtable statmod "1.2-2" "1.5-1" "1.3.1" Dr Peter Dunn (USQ CRICOS No. 00244B) Web: http://www.sci.usq.edu.au/staff/dunn Email: dunn @ usq.edu.au ACSC: http://www.usq.edu.au/acsc This email (including any attached files) is confidentia...{{dropped:15}}
On 07/11/2007 7:01 PM, Peter Dunn wrote:> Hi all > > I have a plot with lines, one specified as (say) lty=1, > using standard line types, and another as (say) my > own spec: lty="51". > > I can't get legend to display both. Toy example: > > >> plot(1~1) >> legend("topright", lty=c("51",1), legend=c("My own","Standard")) > Error in segments(x1, y1, x2, y2, ...) : invalid line type: must be > length 2, 4, 6 or 8 > > > Any ideas?Fairly kludgy idea: plot it twice, once for each style. For example, plot(1 ~ 1) legend("topright", lty=c("55",NA_character_), legend=c("My own","Standard")) legend("topright", lty=c(0,1), legend=c("My own","Standard")) The man page says the NA is not allowed, but it does appear to work. Perhaps there's another way to get blanks using the manual spec. Duncan Murdoch