[Xts-commits] r625 - in pkg/xtsExtra: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu May 31 02:21:23 CEST 2012
Author: weylandt
Date: 2012-05-31 02:21:23 +0200 (Thu, 31 May 2012)
New Revision: 625
Modified:
pkg/xtsExtra/R/old.plot.R
pkg/xtsExtra/R/plot.R
pkg/xtsExtra/man/plot.xts.Rd
Log:
Handle cex, pch, and col better for type = p plots and add examples; hide old plot.xts
Modified: pkg/xtsExtra/R/old.plot.R
===================================================================
--- pkg/xtsExtra/R/old.plot.R 2012-05-30 23:27:45 UTC (rev 624)
+++ pkg/xtsExtra/R/old.plot.R 2012-05-31 00:21:23 UTC (rev 625)
@@ -42,7 +42,8 @@
## E.g. layout(matrix(c(1,2,1,3), ncol = 2) has three time axes -- one underneath the first set of panels, two more for each of the second row
## E.g. layout(matrix(c(1,2,3,1,4,5), ncol=2) has three time axes -- one underneath the first set of panels, two more for each of the third row [since shared with second]
-`plot.xts` <- function(x, y = NULL,
+# UNEXPORTED AND I THINK NOW SUPERCEDED
+`old.plot.xts` <- function(x, y = NULL,
screens, screens.layout,
auto.grid=TRUE,
major.ticks='auto', minor.ticks=TRUE,
@@ -263,4 +264,4 @@
#setup.grid <- function(x){
# # Sets up the axis background for the plot
-#}
\ No newline at end of file
+#}
Modified: pkg/xtsExtra/R/plot.R
===================================================================
--- pkg/xtsExtra/R/plot.R 2012-05-30 23:27:45 UTC (rev 624)
+++ pkg/xtsExtra/R/plot.R 2012-05-31 00:21:23 UTC (rev 625)
@@ -116,12 +116,13 @@
auto.grid = auto.grid, ylab = ylab.panel, log = log.panel)
col.panel <- get.elm.from.dots("col", dots, screens, i)
+ pch.panel <- get.elm.from.dots("pch", dots, screens, i)
+ cex.panel <- get.elm.from.dots("cex", dots, screens, i)
lwd.panel <- get.elm.from.dots("lwd", dots, screens, i)
- pch.panel <- get.elm.from.dots("pch", dots, screens, i)
type.panel <- get.elm.from.dots("type", dots, screens, i)
do_add.lines(x.plot, col = col.panel, lwd = lwd.panel, pch = pch.panel,
- type = type.panel)
+ type = type.panel, cex = cex.panel)
}
}
@@ -218,20 +219,22 @@
box()
}
-do_add.lines <- function(x, col, pch, lwd, type, ...){
+do_add.lines <- function(x, col, pch, cex, lwd, type, ...){
if(is.null(col)) col <- 1:NCOL(x)
if(is.null(pch)) pch <- 1
+ if(is.null(cex)) cex <- 1
if(is.null(lwd)) lwd <- 1
if(is.null(type)) type <- "l"
for(j in 1:NCOL(x)){
col.t <- get.elm.recycle(col, j)
pch.t <- get.elm.recycle(pch, j)
+ cex.t <- get.elm.recycle(cex, j)
lwd.t <- get.elm.recycle(lwd, j)
type.t <- get.elm.recycle(type, j)
- lines(x[,j], col = col.t, pch = pch.t, type = type.t, lwd = lwd.t)
+ lines(x[,j], col = col.t, pch = pch.t, type = type.t, lwd = lwd.t, cex = cex.t)
}
}
@@ -266,5 +269,6 @@
get.elm.from.dots <- function(par, dots, screens, n){
if(!(par %in% names(dots))) NULL else
- get.elm.recycle(split(rep(dots[[par]], length.out = length(screens)), screens), n)
+ get.elm.recycle(split(rep(if(length(levels(screens)) == 1L) list(dots[[par]]) else dots[[par]],
+ length.out = length(screens)), screens), n)
}
Modified: pkg/xtsExtra/man/plot.xts.Rd
===================================================================
--- pkg/xtsExtra/man/plot.xts.Rd 2012-05-30 23:27:45 UTC (rev 624)
+++ pkg/xtsExtra/man/plot.xts.Rd 2012-05-31 00:21:23 UTC (rev 625)
@@ -91,6 +91,23 @@
# Type = "h" nicely illustrates independent points
plot(sample_xts[1:75,1:2] - 50.5, type = c("l","h"), lwd = c(1,2))
+# Type = "p" allows for transparent handling of the pch= argument
+x <- xts(1:5, Sys.Date() + 1:5)
+plot(x, type = "p")
+plot(x, type = "p", pch = 1:5)
+
+# Multivariate recycles over columns
+plot(merge(x,x), type = "p", pch = 1:5)
+
+# Unless you use a list
+plot(merge(x,x), type = "p", pch = list(1:5))
+plot(merge(x,x,x), type = "p", pch = list(1:5, 1:3))
+
+# Same for col= and cex= arguments
+plot(x, type = "p", col = 1:5, pch = 1:5, cex = 1:5)
+plot(merge(x,x), type = "p", col = 1:5, pch = 1:5, cex = 1:5)
+plot(merge(x,x), type = "p", col = list(1:5, 1:3), pch = list(1:5, 1:3), cex = list(1:5, 1:3))
+
# Makes a scatterplot if we pass two series
plot(sample_xts[,1],sample_xts[,2])
More information about the Xts-commits
mailing list