[R] text duplication bug in mtext?

Duncan Murdoch murdoch.duncan at gmail.com
Fri Jan 1 22:56:49 CET 2016


On 01/01/2016 1:36 PM, Arkay 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.

As David said, this is a feature, not a bug.

You were probably confused by the different treatment of "adj" in text() 
and mtext().  The former uses one or two values to determine placement 
of all strings.  The latter uses one value per string.

Duncan Murdoch

>
> 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
>
> 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.
>



More information about the R-help mailing list