[Xts-commits] r834 - pkg/xtsExtra/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Aug 24 14:53:45 CEST 2014
Author: rossbennett34
Date: 2014-08-24 14:53:45 +0200 (Sun, 24 Aug 2014)
New Revision: 834
Modified:
pkg/xtsExtra/R/plot2.R
Log:
adding arguments to allow rotating x and y axis labels
Modified: pkg/xtsExtra/R/plot2.R
===================================================================
--- pkg/xtsExtra/R/plot2.R 2014-08-23 16:19:49 UTC (rev 833)
+++ pkg/xtsExtra/R/plot2.R 2014-08-24 12:53:45 UTC (rev 834)
@@ -97,7 +97,10 @@
main=deparse(substitute(x)),
clev=0,
cex=0.6,
+ cex.axis=0.9,
mar=c(3,2,0,2),
+ srt=0,
+ xaxis.las=0,
ylim=NULL,
yaxis.same=TRUE,
yaxis.left=TRUE,
@@ -172,7 +175,10 @@
main=main,
clev=clev,
cex=cex,
+ cex.axis=cex.axis,
mar=mar,
+ srt=srt,
+ xaxis.las=xaxis.las,
ylim=ylim,
yaxis.same=yaxis.same,
yaxis.left=yaxis.left,
@@ -270,6 +276,9 @@
cs$Env$theme$grid <- grid.col
cs$Env$theme$grid2 <- grid2
cs$Env$theme$labels <- labels.col
+ cs$Env$theme$srt <- srt
+ cs$Env$theme$xaxis.las <- xaxis.las
+ cs$Env$theme$cex.axis <- cex.axis
#cs$Env$theme$label.bg <- label.bg
cs$Env$theme$coarse.time <- coarse.time
cs$Env$format.labels <- format.labels
@@ -370,7 +379,7 @@
axt <- axis_ticks(xdata,xsubset),
text(as.numeric(axt),
par('usr')[3]-0.2*min(strheight(axt)),
- names(axt),xpd=TRUE,cex=0.9,pos=3)),
+ names(axt),xpd=TRUE,cex=theme$cex.axis,pos=3)),
clip=FALSE,expr=TRUE)
# Add frame for the chart "header" to display the name and start/end dates
@@ -385,7 +394,8 @@
cs$add(expression(axt <- axTicksByTime(xdata[xsubset],format.labels=format.labels),
axis(1,at=axt, #axTicksByTime(xdata[xsubset]),
labels=names(axt), #axTicksByTime(xdata[xsubset],format.labels=format.labels)),
- las=1,lwd.ticks=1,mgp=c(3,1.5,0),tcl=-0.4,cex.axis=.9)),
+ las=theme$xaxis.las, lwd.ticks=1, mgp=c(3,1.5,0),
+ tcl=-0.4, cex.axis=theme$cex.axis)),
expr=TRUE)
# add main and start/end dates
@@ -422,14 +432,16 @@
expression(text(1-1/3-max(strwidth(y_grid_lines(constant_ylim))),
y_grid_lines(constant_ylim),
noquote(format(y_grid_lines(constant_ylim), justify="right")),
- col=theme$labels, offset=0, pos=4, cex=0.9, xpd=TRUE)))
+ col=theme$labels, srt=theme$srt, offset=0, pos=4,
+ cex=theme$cex.axis, xpd=TRUE)))
}
if(yaxis.right){
exp <- c(exp,
# right y-axis labels
expression(text(NROW(R[xsubset])+1/3, y_grid_lines(constant_ylim),
noquote(format(y_grid_lines(constant_ylim), justify="right")),
- col=theme$labels, offset=0, pos=4, cex=0.9, xpd=TRUE)))
+ col=theme$labels, srt=theme$srt, offset=0, pos=4,
+ cex=theme$cex.axis, xpd=TRUE)))
}
cs$add(exp, env=cs$Env, expr=TRUE)
@@ -516,13 +528,15 @@
# y-axis labels/boxes
expression(text(1-1/3-max(strwidth(y_grid_lines(ylim))), y_grid_lines(ylim),
noquote(format(y_grid_lines(ylim),justify="right")),
- col=theme$labels,offset=0,pos=4,cex=0.9, xpd=TRUE)))
+ col=theme$labels, srt=theme$srt, offset=0,
+ pos=4, cex=theme$cex.axis, xpd=TRUE)))
}
if(yaxis.right){
exp <- c(exp,
expression(text(NROW(xdata[xsubset])+1/3, y_grid_lines(ylim),
noquote(format(y_grid_lines(ylim),justify="right")),
- col=theme$labels,offset=0,pos=4,cex=0.9, xpd=TRUE)))
+ col=theme$labels, srt=theme$srt, offset=0,
+ pos=4, cex=theme$cex.axis, xpd=TRUE)))
}
cs$add(exp,env=c(lenv, cs$Env),expr=TRUE,no.update=TRUE)
}
More information about the Xts-commits
mailing list