An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120905/6d189292/attachment.pl>
cex.lab ignored in plot.zoo for multiple plots
6 messages · Nicolai Schneider, David Winsemius, A Duranel +1 more
On Sep 5, 2012, at 8:06 AM, Nicolai Schneider wrote:
Hello everyone, a problem with the plot.zoo function. In the parameters of the function, cex.lab is ignored. I tried to reduce the size of the yaxis labels by at least 50%. ------------------ Example: sample <- as.zoo(EuStockMarkets) par(las=1) plot.zoo(sample, plot.type="multiple", main="Time Series", xlab="Date", yaxt="n", cex.lab=0.5, xaxs="i") # Try playing with different values for cex.lab
I would have thought that the parameter to use would be 'cex.axis'. Testing seems to confirm theory in this case.
par(las=0) ---------------
David Winsemius, MD Alameda, CA, USA
5 days later
Sep 05, 2012; 6:39pm ? by David Winsemius David Winsemius
a problem with the plot.zoo function. In the parameters of the function, cex.lab is ignored. I tried to reduce the size of the yaxis labels by at least 50%. Example: sample <- as.zoo(EuStockMarkets) par(las=1) plot.zoo(sample, plot.type="multiple", main="Time Series", xlab="Date", yaxt="n", cex.lab=0.5, xaxs="i") # Try playing with different values for cex.lab
I would have thought that the parameter to use would be 'cex.axis'. Testing
seems to confirm theory in this case. I have the same issue (R 2.13.0 & zoo_1.7-6). cex.lab, col.lab and font.lab are ignored, whether in the plot() or par() statement (and so is ann=FALSE by the way). Contrary to David's suggestion, cex.axis changes the size of axis tick labels (removed in the example above), not of the axis label. Thanks Arnaud. -- View this message in context: http://r.789695.n4.nabble.com/cex-lab-ignored-in-plot-zoo-for-multiple-plots-tp4642295p4642759.html Sent from the R help mailing list archive at Nabble.com.
On Wed, Sep 5, 2012 at 11:06 AM, Nicolai Schneider
<rstatistics.user at gmail.com> wrote:
Hello everyone, a problem with the plot.zoo function. In the parameters of the function, cex.lab is ignored. I tried to reduce the size of the yaxis labels by at least 50%. ------------------ Example: sample <- as.zoo(EuStockMarkets) par(las=1) plot.zoo(sample, plot.type="multiple", main="Time Series", xlab="Date", yaxt="n", cex.lab=0.5, xaxs="i") # Try playing with different values for cex.lab par(las=0)
Internally it uses mtext to write that text and mtext uses cex which is already taken. Here is a workaround: library(proto) p <- proto(plot.zoo = plot.zoo, mtext = function(...) graphics::mtext(..., cex = .5)) with(p, plot.zoo)(sample)
Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
On Sep 11, 2012, at 7:48 AM, Gabor Grothendieck wrote:
On Wed, Sep 5, 2012 at 11:06 AM, Nicolai Schneider <rstatistics.user at gmail.com> wrote:
Hello everyone, a problem with the plot.zoo function. In the parameters of the function, cex.lab is ignored. I tried to reduce the size of the yaxis labels by at least 50%. ------------------ Example: sample <- as.zoo(EuStockMarkets) par(las=1) plot.zoo(sample, plot.type="multiple", main="Time Series", xlab="Date", yaxt="n", cex.lab=0.5, xaxs="i") # Try playing with different values for cex.lab par(las=0)
Internally it uses mtext to write that text and mtext uses cex which is already taken. Here is a workaround: library(proto) p <- proto(plot.zoo = plot.zoo, mtext = function(...) graphics::mtext(..., cex = .5)) with(p, plot.zoo)(sample)
So that creates an R environment where you are creating an unmodified instance of the plot.zoo function as well as installing a genetically-modified instance of mtext which has a redefinition of the parameter list to graphics::mtext()? (So using `(... , arg=newval)` is an acceptable way to over-rule a parameter list assignment? It certainly seems to be.) So when you access access that p-instance of plot.zoo(), it finds this new "genetically-modified" instance of mtext() because it is in the same environment? And the reason it doesn't work to just redefine mtext (I tried) is that it would be in an environment that plot.zoo would not examine first when called from the command line?
David Winsemius, MD Alameda, CA, USA
On Tue, Sep 11, 2012 at 2:54 PM, David Winsemius <dwinsemius at comcast.net> wrote:
On Sep 11, 2012, at 7:48 AM, Gabor Grothendieck wrote:
On Wed, Sep 5, 2012 at 11:06 AM, Nicolai Schneider <rstatistics.user at gmail.com> wrote:
Hello everyone, a problem with the plot.zoo function. In the parameters of the function, cex.lab is ignored. I tried to reduce the size of the yaxis labels by at least 50%. ------------------ Example: sample <- as.zoo(EuStockMarkets) par(las=1) plot.zoo(sample, plot.type="multiple", main="Time Series", xlab="Date", yaxt="n", cex.lab=0.5, xaxs="i") # Try playing with different values for cex.lab par(las=0)
Internally it uses mtext to write that text and mtext uses cex which is already taken. Here is a workaround: library(proto) p <- proto(plot.zoo = plot.zoo, mtext = function(...) graphics::mtext(..., cex = .5)) with(p, plot.zoo)(sample)
So that creates an R environment where you are creating an unmodified instance of the plot.zoo function as well as installing a genetically-modified instance of mtext which has a redefinition of the parameter list to graphics::mtext()? (So using `(... , arg=newval)` is an acceptable way to over-rule a parameter list assignment? It certainly seems to be.) So when you access access that p-instance of plot.zoo(), it finds this new "genetically-modified" instance of mtext() because it is in the same environment? And the reason it doesn't work to just redefine mtext (I tried) is that it would be in an environment that plot.zoo would not examine first when called from the command line?
Yes, proto changes the environment of plot.zoo when its inserted into p.
For comparison it could be done like this without proto:
e <- local({
mtext <- function(...) graphics::mtext(..., cex = 0.5)
environment(plot.zoo) <- environment()
})
with(e, plot.zoo)(sample)
Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com