[R] mtext bug

Duncan Murdoch murdoch.duncan at gmail.com
Sun Jun 3 11:08:32 CEST 2012


On 12-06-02 8:42 PM, Matthew Johnson wrote:
> Sir,
>
> I am now having a similar problem with the barplot: i cannot get the
> margin text to 'stick'.
>
> png(paste(drive, "MoMUnit.png", sep=""))
> par(mar=c(10, 3, 2, 2), opar=(1,0,0,0))

I think "opar" is a typo.

Duncan Murdoch

> mainnameUnit = expression(paste("MoM %", Delta, " Apptmnt Prices", sep=""))
> ymin <- min(percentDiff[,c(6, 9, 33, 36, seq(15,30,3), 3)]) -1
> ymax <- max(percentDiff[,c(6, 9, 33, 36, seq(15,30,3), 3)]) +1
> barplot(percentDiff[,c(6, 9, 33, 36, seq(15,30,3), 3)], las=2, beside=T,
> ylim=c(ymin, ymax), legend.text=c(prior2m, prior1m, ee),
>          main=mainnameUnit)
> mtext(stamp, cex=0.75, line=0, side=1, adj=1, outer=T)
> mtext("Source: ASX", cex=0.75, side=1, adj=0, outer=T)
> dev.off()
>
> i also have a few assorted issues that i cannot figure out -- i would
> like to remove the box around the bar plot, and add some intro text
> above the key, as i have done in the line plot case.
>
> thanks and best regards
>
> matt johnson
>
> On 3 June 2012 08:38, Matthew Johnson <mcooganj at gmail.com
> <mailto:mcooganj at gmail.com>> wrote:
>
>     thanks very much - fixed.
>
>
>     On 3 June 2012 08:26, Duncan Murdoch <murdoch.duncan at gmail.com
>     <mailto:murdoch.duncan at gmail.com>> wrote:
>
>         On 12-06-02 6:21 PM, Matthew Johnson wrote:
>
>             Sir,
>
>             I have hit a the limits of my understanding of text / par /
>             opar etc...
>
>             I have a few related xts data frames which have multiple
>             columns, and have
>             written a for-loop to make a set of charts - however i do
>             not get any
>             margin text when i run the loop.
>
>             when i test the code outside of the loop the margin text
>             appears - however
>             when i run the loop the margin text does not appear ... what
>             gives?
>
>
>         You're calling par() before png().  Your par() settings will
>         apply to the device that was active before you open the png()
>         device, not to it.
>
>         Duncan Murdoch
>
>
>             here is the code
>
>             for (col in 1:ncol(xdf)){
>                par(mar=c(3.5, 4.5, 2, 1), oma=c(2,0,0,0))
>                ymin = min(xdf[,col]) - 20
>                ymax = max(xdf[,col]) + 20
>                png(paste(drive, names(xdf)[col], '.png', sep=""))
>                plot(coredata(yr09_10[,col]), type='l', ylim=c(ymin,
>             ymax), col=1, lwd=2,
>             las=1, xlab="", ylab="",
>                     xaxt='n', main=names(xdf)[col])
>                lines(coredata(yr10_11[,col]), col=2, lwd=2)
>                lines(coredata(yr11_12[,col]), col=3, lwd=2)
>                axis(1, at=c(1:365), labels=format(index(yr09_10),
>             "%d-%b"), tck=0.01,
>             las=1)
>                legend("bottom", inset=0.02, title="Financial Years",
>             c("09/10", "10/11",
>             "11/12"), col=c(1,2,3), lwd=3, horiz=TRUE, bty='n')
>                mtext(stamp, cex=0.75, line=0, side=1, adj=1, outer=T)
>                mtext("Source: ABS", cex=0.75, side=1, adj=0, outer=T)
>                dev.off()
>             }
>
>             the charts are certainly re-made each time (i've checked
>             this!) and they
>             appear as desired, excepting the absence of the margin text.
>
>             could anyone please help?
>
>             tips on any other aspects of the above code are also very
>             welcome.
>
>             thanks and best regards
>
>             matt johnson
>
>                     [[alternative HTML version deleted]]
>
>             ______________________________ ________________
>             R-help at r-project.org <mailto:R-help at r-project.org> mailing list
>             https://stat.ethz.ch/mailman/ listinfo/r-help
>             <https://stat.ethz.ch/mailman/listinfo/r-help>
>             PLEASE do read the posting guide http://www.R-project.org/
>             posting-guide.html <http://www.R-project.org/posting-guide.html>
>             and provide commented, minimal, self-contained, reproducible
>             code.
>
>
>
>



More information about the R-help mailing list