[R] text duplication bug in mtext?

David Winsemius dwinsemius at comcast.net
Fri Jan 1 21:57:54 CET 2016


> On Jan 1, 2016, at 10:36 AM, Arkay <arkay7777 at gmail.com> wrote:
> 
> Not sure if this has already been reported but I think that there might 
> be a bug in mtext that causes the text in a plot to be duplicated under 
> a narrow set of circumstances.
> 
> Here is a reproducible example.
> 
> df1 <- data.frame(V1=rnorm(100))
> hist(df1$V1)
> mtext("Test", side=1, line=4, adj=c(1,0)) # causes text to appear 
> twice
> 

If you do this:

mtext("Test", side=1, line=4, adj=seq(0,1, length=5) )


You get 5 items.  It's arguably a "feature", and arguably documented where the help page says: "All of the named arguments can be vectors, and recycling will take place to plot as many strings as the longest of the vector arguments."

David.

> This does not appear to happen if adj=c(0,0) or if the adj argument is 
> removed altogether:
> 
> hist(df1$V1)
> mtext("Test", side=1, line=4, adj=c(0,0))
> 
> Furthermore, it looks like using the "at" argument causes the spacing 
> between the duplicated text to disappear:
> 
> hist(df1$V1)
> mtext("Test", side=1, line=4, at=0, adj=c(1,0))
> 
> Some additional information related to my R installation.
> 
> sessionInfo()
> R version 3.2.3 (2015-12-10)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 8.1 x64 (build 9600)
> 
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United 
> States.1252    LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C                           LC_TIME=English_United 
> States.1252    
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base     
> 
> other attached packages:
> [1] rj_2.0.3-2
> 
> loaded via a namespace (and not attached):
> [1] tools_3.2.3
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list