Jan Verbesselt
2005-Dec-07 15:19 UTC
[R] Change labels of x-axes in Plot of stl() function?
Hi all, How can the label of the x-axes in the plot() of a stl.object be adapted? e.g., When plotting: plot(stl(nottem, "per")) In the labels of the x-axes is “time”. How can this be changed to e.g., “Time (dekade) “? It does not work with xlab or others anymore… Thanks, Jan _______________________________________________________________________ Ir. Jan Verbesselt Research Associate Biosystems Department ~ M³-BIORES Vital Decosterstraat 102, 3000 Leuven, Belgium Tel: +32-16-329750 Fax: +32-16-329760 http://gloveg.kuleuven.ac.be/ _______________________________________________________________________ Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm [[alternative HTML version deleted]]
Gabor Grothendieck
2005-Dec-07 16:06 UTC
[R] Change labels of x-axes in Plot of stl() function?
If you look through the output of: stats:::plot.stl you see right near the end that "time" is hard coded in the call to mtext. However, we could temporarily redefine mtext so that it works as you wish and then redefine plot.stl so that it looks within the environment of our function to find mtext (rather than looking in the stats package): plot.stl <- function(..., xlab = "time") { mtext <- function(text, ...) graphics::mtext(xlab, ...) plot.stl <- stats:::plot.stl environment(plot.stl) <- environment() plot.stl(...) } # test it example(stl) plot.stl(stmd, xlab = "X") On 12/7/05, Jan Verbesselt <Jan.Verbesselt at biw.kuleuven.be> wrote:> Hi all, > > How can the label of the x-axes in the plot() of a stl.object be adapted? > > e.g., > > When plotting: plot(stl(nottem, "per")) > > In the labels of the x-axes is "time". How can this be changed to e.g., > "Time (dekade) "? > > It does not work with xlab or others anymore > > > > Thanks, > > Jan > > _______________________________________________________________________ > Ir. Jan Verbesselt > Research Associate > Biosystems Department ~ M-BIORES > Vital Decosterstraat 102, 3000 Leuven, Belgium > Tel: +32-16-329750 Fax: +32-16-329760 > http://gloveg.kuleuven.ac.be/ > _______________________________________________________________________ > > > > > > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > >
Jan Verbesselt
2005-Dec-07 17:01 UTC
[R] Change labels of x-axes in Plot of stl() function?
Thanks a lot! However, it?s not working perfectly yet. The function plot.stl now also changes the labels of Data, Seasonal, Trend, and Remainder to the text defined for ?xlab?. How could this be fine-tuned? Regards, Jan> -----Original Message----- > From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] > Sent: Wednesday, December 07, 2005 5:07 PM > To: Jan Verbesselt > Cc: r-help at stat.math.ethz.ch > Subject: Re: [R] Change labels of x-axes in Plot of stl() function? > > If you look through the output of: > > stats:::plot.stl > > you see right near the end that "time" is hard coded in the call to mtext. > > However, we could temporarily redefine mtext so that it works as you > wish and then redefine plot.stl so that it looks within the environment > of our function to find mtext (rather than looking in the stats package): > > plot.stl <- function(..., xlab = "time") { > mtext <- function(text, ...) graphics::mtext(xlab, ...) > plot.stl <- stats:::plot.stl > environment(plot.stl) <- environment() > plot.stl(...) > } > > # test it > example(stl) > plot.stl(stmd, xlab = "X") > > > > On 12/7/05, Jan Verbesselt <Jan.Verbesselt at biw.kuleuven.be> wrote: > > Hi all, > > > > How can the label of the x-axes in the plot() of a stl.object be > adapted? > > > > e.g., > > > > When plotting: plot(stl(nottem, "per")) > > > > In the labels of the x-axes is "time". How can this be changed to e.g., > > "Time (dekade) "? > > > > It does not work with xlab or others anymore> > > > > > > > Thanks, > > > > Jan > > > > _______________________________________________________________________ > > Ir. Jan Verbesselt > > Research Associate > > Biosystems Department ~ M??-BIORES > > Vital Decosterstraat 102, 3000 Leuven, Belgium > > Tel: +32-16-329750 Fax: +32-16-329760 > > http://gloveg.kuleuven.ac.be/ > > _______________________________________________________________________ > > > > > > > > > > > > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm > > > > > > [[alternative HTML version deleted]] > > > > > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! http://www.R-project.org/posting- > guide.html > > > >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
Possibly Parallel Threads
- Penalized likelihood-ratio chi-squared statistic: L.R. model for Goodness of fit?
- HOW to Create Movies with R with repeated plot()?
- How to add legend of plot.Design function (method=image)? (if (!.R.) )
- How to add values on the axes of the 3D bi-variable lrm fit?
- how to optimise cross-correlation plot to study time lag between time-series?