[Xts-commits] r702 - in pkg/xtsExtra: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Aug 7 05:02:50 CEST 2012
Author: weylandt
Date: 2012-08-07 05:02:49 +0200 (Tue, 07 Aug 2012)
New Revision: 702
Modified:
pkg/xtsExtra/R/plot.R
pkg/xtsExtra/man/plot.xts.Rd
Log:
Actual fix for the bug attempted in r701; that fix did nothing
Modified: pkg/xtsExtra/R/plot.R
===================================================================
--- pkg/xtsExtra/R/plot.R 2012-08-07 00:40:33 UTC (rev 701)
+++ pkg/xtsExtra/R/plot.R 2012-08-07 03:02:49 UTC (rev 702)
@@ -133,7 +133,7 @@
do_add.grid(x.plot, major.ticks, major.format, minor.ticks,
auto.grid = auto.grid, ylab = ylab.panel, log = log.panel,
have_x_axis = have_x_axis[i], have_y_axis = have_y_axis[i],
- ylab.axis = ylab.axis[as.vector(layout.screens)][layout.screens == i][1],
+ ylab.axis = ylab.axis[which.max(layout.screens == i)], # Use which.max to get first hit
events = events, blocks = blocks,
yax.loc = yax.loc, ylim = get.elm.recycle(ylim, i))
@@ -234,21 +234,21 @@
# From this part, we return a vector ylab.axis giving L/R/None marks for y-labels
# Margins are set appropriately back in main function body
- if(yax.loc == "none") ylab.axis <- rep("none", length.out = length(have_y_axis))
+ ylab.axis <- layout.screens
+ if(yax.loc == "none") ylab.axis[] <- "none"
+
# If labels are set to left/right we need them in all panels
if(yax.loc == "right" || yax.loc == "left") {
have_y_axis[] <- TRUE # Since forcing labels, we write a y-axis everywhere
- ylab.axis <- rep(yax.loc, length.out = length(have_y_axis))
+
+ ylab.axis[] <- yax.loc
}
if(yax.loc == "out" || yax.loc == "in"){
if(NCOL(layout.screens) != 2L) stop("yax.loc not consistent with layout -- too many columns.")
# If labels are set to out we need them for outer panels only
# If labels are set to in we need them for inner panels only
-
- ylab.axis <- layout.screens
-
ylab.axis[,1] <- if(yax.loc == "out") "left" else "right"
ylab.axis[,2] <- if(yax.loc == "out") "right" else "left"
have_y_axis[] <- TRUE # Axes for all if TRUE
@@ -256,7 +256,6 @@
# If labels are set to flip we do a little bit of work to arrange them
if(yax.loc == "flip") {
- ylab.axis <- layout.screens
for(i in seq_len(NCOL(ylab.axis))) ylab.axis[,i] <- rep(c("left","right"), length.out = NROW(ylab.axis))
have_y_axis[] <- TRUE
}
Modified: pkg/xtsExtra/man/plot.xts.Rd
===================================================================
--- pkg/xtsExtra/man/plot.xts.Rd 2012-08-07 00:40:33 UTC (rev 701)
+++ pkg/xtsExtra/man/plot.xts.Rd 2012-08-07 03:02:49 UTC (rev 702)
@@ -99,6 +99,18 @@
# Type = "h" nicely illustrates independent points
plot(sample_xts[1:75,1:2] - 50.5, type = c("l","h"), lwd = c(1,2))
+# Arrangement of axis-labels
+plot(sample_xts[,1:3], layout = matrix(c(1,1,2,3), ncol = 2, byrow = TRUE), yax.loc = "none")
+plot(sample_xts[,1:3], layout = matrix(c(1,1,2,3), ncol = 2, byrow = TRUE), yax.loc = "left")
+plot(sample_xts[,1:3], layout = matrix(c(1,1,2,3), ncol = 2, byrow = TRUE), yax.loc = "right")
+
+plot(sample_xts, layout = matrix(1:4, ncol = 2), yax.loc = "in")
+plot(sample_xts, layout = matrix(1:4, ncol = 2), yax.loc = "out")
+plot(sample_xts, layout = matrix(1:4, ncol = 2), yax.loc = "flip")
+
+plot(sample_xts[,c(1:4, 3:4)], layout = matrix(c(1,1,1,1,2,2,3,4,5,6), ncol = 2, byrow = TRUE), yax.loc = "in")
+
+
# Type = "p" allows for transparent handling of the pch= argument
x <- xts(1:5, Sys.Date() + 1:5)
plot(x, type = "p")
More information about the Xts-commits
mailing list